Perhaps the most basic and obvious use of CSS custom properties is design tokens. Colors, fonts, spacing, timing, and other design elements that you can bring in when designing your site. if you quite a lot By simply taking the value from the design token, you are directed towards a clean design and a consistent professional look, which is the goal of web design in general. In fact, I wrote that this is exactly what I think contributes to the popularity of utility class frameworks.
Part of its popularity claims to be due to the fact that the design is quite nice if you choose from these pre-configured classes. You can’t get off the rails. You are choosing from a limited set of nicely designed values.
I’m saying this (using a stylesheet that defines this class as a single styling action token).
<h1 class="color-primary size-large">Header<h1>
… is a value proposition similar to:
html {
--color-primary: green;
--size-large: 3rem;
/* ... and a whole set of tokens */
}
h1 {
color: var(--color-primary);
font-size: var(--size-large);
}
Both have zero build versions. E.g, Tachyon It’s just a stylesheet with lots of utility classes to use. windy It’s totally cool with Just-In-Time compilers, etc. pot It’s a library of out-of-the-box custom properties and is a completely new open props Have just-in-time compiler Pass only custom properties that are used.
right, so open props!
Everything is literally a whole pile of CSS custom properties that you can use in your design. It’s like a huge starting point for your style. are you saying all custom properties, but we are already accustomed to design tokens, which are a limited number of pre-determined choices.
The analogy is clear to people.
What draws people here, I think, is a beautiful default.
what I never do that You don’t have to give it a name that any utility class enthusiast I know really likes. You’ll still need to use the generic ol’ CSS selectors (eg named classes) to select and style items as you “normally” do here. However, instead of creating your own values by hand, you extract values from these custom properties.
The whole basics (you view source here) over the wire to 4.4kb (which is what my DevTools showed me anyway). This doesn’t include the CSS you write to use your custom properties, but it’s a pretty small amount of overhead. There are additional PropPacks that increase the size (but supervisor very small), and if you’re concerned about size, that’s all Just-In-Time matters. you can play with it on StackBlitz.
Seems pretty sweet to me! i will use it I like that it’s ultimately just plain CSS, so there’s nothing you can’t do. It will be in good shape as CSS evolves.