How To Set Default Color In Tailwindcss 4 For A Rails App
Application.css looks like this:
```css
@import "tailwindcss";
@theme {
--brand-color: oklch(0.35 0.2153 266.44);
}
@layer base {
html {
@apply text-(--brand-color);
}
}
so the color gets defined in the @theme
directive, and it then gets applied by the base layer.
There are other ways, but this seems to me the cleanest, and when universally needed, the right choice.
Maybe when dynamic application of themes is important, it might be easier to manipulate the body
tag like so:
<body class="text-{color}">
wwwwwwwwwwwwwwwwwyou might still have to define the color somewhere if it is a custom choice.
Hey! I'll happily receive your comments
via email.
Thanks for reading.

Andreas Wagner
freelance System Administrator and Ruby programmer in Tallinn, Estonia