Toggle theme

CSS in JS🔗

The styling engine behind VCC UI is built on top of Fela - A small, high-performant and framework-agnostic tool belt to handle state-driven styling in JavaScript.

How it works🔗

The rendering methodology used is often referred to as atomic or virtual CSS, this means that each property is compiled down to a single className and then re-used across components. This allows us to only ship the minimal CSS required to render a specific page.

The following page:

Will typically render the following CSS and HTML:

Caveats🔗

While we think the atomic CSS approach generally works and scales really well, there are few key considerations to be aware of

Probably the biggest downside of using atomic CSS design, is the fact that shorthand and longhand properties can't safely be mixed in a single rule.

Read more about why, in the Fela documentation. To mitigate developers running in to this, we're currently working on showing a console.warn when shorthand and longhand properties are mixed unintentionally.

Styling specific components is easy, but what about global styles? While generally not recommended, you can use the renderer to specify arbitrary global CSS (like "reset" styles) if you wish

2022 © Volvo Car Corporation