/rails-css-component-techniques

Examples of ways to encapsulate Rails View Component CSS

Primary LanguageRuby

Rails View Component based CSS encapsulation

Demonstrates a technique to automatically encapsulate View Component sidecar CSS. When writing sidecar css simply use the ::component psuedo-element selector to reference the component under development, and a class will be generated and your component will be wrapped in it.

See the feature's PR to find the interesting bits from the Rails cruft.

If you don't want to download and run yourself, here's the relevant results:

Rendered

Rendered output

CSS Output

CSS output

HTML Output

HTML output