Styling
You can put a style
tag inside. Riot.js automatically takes it out and injects it into <head>
. This happens once, no matter how many times the component is initialized.
<my-component>
<!-- layout -->
<h3>{ props.title }</h3>
<style>
/** other component specific styles **/
h3 { font-size: 120% }
/** other component specific styles **/
</style>
</my-component>
Scoped CSS
Scoped css and :host pseudo-class) is also available for all browsers. Riot.js has its own custom implementation in JS which does not rely on or fallback to the browser implementation. The example below is equivalent to the first one. Notice that the example below uses the :host
pseudo-class
instead of relying in the component name to scope the styles.
<my-component>
<!-- layout -->
<h3>{ props.title }</h3>
<style>
:host { display: block }
h3 { font-size: 120% }
/** other component specific styles **/
</style>
</my-component>