DEV Community


Discussion on: Dynamic CSS in Svelte

dimfeld profile image
Daniel Imfeld Author • Edited

Yeah, I use PostCSS for those purposes along with Tailwind CSS. Definitely makes things more convenient when you can define things in one place and use them throughout the application.

CSS Variables like I described in this article are most useful when you can't predict the values needed at build time. I have a couple examples of this embedded in the page on the version of this post on my actual website or you can also check it out on this Svelte REPL example.

Here's another cool example not by me, where CSS variables are used to selectively change the style on certain elements of a design:

Thanks for reading!