Stencil

A toolchain for building scalable, enterprise-ready component systems on to...

README

stencil-logo

  Stencil

A compiler for generating Web Components, built by the Ionic team.

Stencil allows developers to use technologies like TypeScript and JSX to define components, then generate 100% standards-based Web Components that run on both modern browsers and legacy browsers

StencilJS is released under the MIT license. StencilJS is released under the MIT license. PRs welcome! Follow @stenciljs

Quick Start · Documentation · Contribute · Blog
  Community:
Slack · Forums · Twitter


Getting Started


Start a new project by following our quick Getting Started guide.
We would love to hear from you!
If you have any feedback or run into issues using Stencil, please file an issue on this repository.

Examples

A Stencil component looks a lot like a class-based React component, with the addition of TypeScript decorators:
  1. ```tsx
  2. import { Component, Prop, h } from '@stencil/core';

  3. @Component({
  4.   tag: 'my-component',            // the name of the component's custom HTML tag
  5.   styleUrl: 'my-component.css',   // css styles to apply to the component
  6.   shadow: true,                   // this component uses the ShadowDOM
  7. })
  8. export class MyComponent {
  9.   // The component accepts two arguments:
  10.   @Prop() first: string;
  11.   @Prop() last: string;

  12.    //The following HTML is rendered when our component is used
  13.   render() {
  14.     return (
  15.       <div>
  16.         Hello, my name is {this.first} {this.last}
  17.       </div>
  18.     );
  19.   }
  20. }
  21. ```

The component above can be used like any other HTML element:

  1. ```html
  2. <my-component first="Stencil" last="JS"></my-component>
  3. ```

Since Stencil generates web components, they work in any major framework or with no framework at all.
In many cases, Stencil can be used as a drop in replacement for traditional frontend framework, though using it as such is certainly not required.

Contributing


Thanks for your interest in contributing!
Please take a moment to read up on our guidelines for contributing.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Thanks

Stencil's internal testing suite is supported by the BrowserStack Open-Source Program