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.

  1. <my-component>
  2. <!-- layout -->
  3. <h3>{ props.title }</h3>
  4. <style>
  5. /** other component specific styles **/
  6. h3 { font-size: 120% }
  7. /** other component specific styles **/
  8. </style>
  9. </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.

  1. <my-component>
  2. <!-- layout -->
  3. <h3>{ props.title }</h3>
  4. <style>
  5. :host { display: block }
  6. h3 { font-size: 120% }
  7. /** other component specific styles **/
  8. </style>
  9. </my-component>