A compiler for generatingWeb Componentsusing technologies like TypeScript and JSX, built by theIonic team.
Quick Start
·
Documentation
·
Contribute
·
Blog
Community:
Discord
·
Forums
·
Twitter
Start a new project by following our quickGetting Started guide. We would love to hear from you! If you have any feedback or run into issues using Stencil, please file anissueon this repository.
A Stencil component looks a lot like a class-based React component, with the addition of TypeScript decorators:
import{Component,Prop,h}from'@stencil/core';
@Component({
tag:'my-component',// the name of the component's custom HTML tag
styleUrl:'my-component.css',// css styles to apply to the component
shadow:true,// this component uses the ShadowDOM
})
exportclassMyComponent{
// The component accepts two arguments:
@Prop()first:string;
@Prop()last:string;
//The following HTML is rendered when our component is used
render(){
return(
<div>
Hello, my name is{this.first}{this.last}
</div>
);
}
}
The component above can be used like any other HTML element:
<my-componentfirst= "Stencil"last= "JS"></my-component>
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.
Thanks for your interest in contributing! Please take a moment to read up on our guidelines forcontributing. Please note that this project is released with aContributor Code of Conduct.By participating in this project you agree to abide by its terms.