Join the Webstudio community

Updated last month

Semantic CSS vs Tokens questions

At a glance
Have been looking throughout here and online to see how we can use custom classes in place of tokens.

So on the front end tokens are great, they act really similar to css utility classes. However when you go to the developer it outputs one class for every style. I read that this was the automatic code behind the scenes within web studio.

The same thing I noticed when I enter in the advanced css
“Border-radius : 30px”

Instead of the short hand it takes that and creates all the side variations- left, top, bottom, right.

So a few questions is there a way to turn all of this off and use semantic css classes and utility classes with vars?

Or why does it do this? Front end it get it. The developer side… it is a pain!
O
A
B
7 comments
Hi, can you describe your use case? what are you trying to achieve
Is your goal to generate code with webstudio and then copy it over to your custom code base?
are you aware of the atomic css setting?
So for example in these images below. They all share the same token, "btn" Even with the atomic CSS off, it still generates it own seperate CSS Class. 3 different classes doing the exact same thing " W-heading-1" " W-button" "W-link-1" When simply all they need is just one common class as in "btn" the token class.
And also yes the ability to write the css as

.btn {
padding: 10px 30px;
color: black;
text-decoration: none;
font-size: var(--text-s)
}

something like this. So this would be the css class I am able to assign in the tokens area.
Here's a proposal to support native mixins which are exactly what tokens are
https://css.oddbird.net/sasslike/mixins-functions/

Classes are not composable so we support them only to let users leverage them in html embed
What about the ability to follow this style of buildouts?

https://getbem.com/
Add a reply
Sign up and join the conversation on Discord