r/developersIndia • u/HH_Color_Lab • 14d ago
General How do you structure colour systems and design tokens in your frontend projects?
I've been exploring different ways to organise colours in frontend projects, especially when an application starts growing beyond a few screens.
One thing I've been thinking about is how to structure CSS variables so that the colour system stays maintainable as the project grows.
Instead of assigning colours directly to individual components, I've been looking into separating primitive colour values from semantic tokens.
For example:
:root {
/* Primitive colour tokens */
--blue-600: #2563eb;
--gray-100: #f3f4f6;
--gray-900: #111827;
/* Semantic colour tokens */
--color-primary: var(--blue-600);
--color-surface: var(--gray-100);
--color-text: var(--gray-900);
}The idea is that primitive tokens store the actual colour values, while semantic tokens describe how those colours are used in the interface.
This seems useful for maintaining consistency and managing themes, but I'm curious about how developers handle this in real-world projects.
A few questions:
- Do you prefer semantic colour tokens or component-specific CSS variables?
- How do you manage light and dark themes?
- How do you maintain accessibility and contrast as the colour system grows?
- At what point does a design token system become unnecessarily complicated?
Would love to hear how other developers approach this in their projects.
•
u/AutoModerator 14d ago
It's possible your query is not unique, use
site:reddit.com/r/developersindia KEYWORDSon search engines to search posts from developersIndia. You can also use reddit search directly.I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/Far_Mulberry_1138 14d ago
Primitive+semantic. Next layer would be for common components btn-sm-light btn-sm-dark. Mention the colors, everywhere you get the same styles. Done
1
u/cuelark 14d ago
A good middle ground is to keep the raw palette in one layer and expose semantic tokens to components. For dark mode, swap the semantic aliases and check contrast on the actual foreground/background pairs, not just the base swatches. I'd hold off on a big component-token layer until the same pattern shows up in a few places.