Menu

One set of CSS tokens, two themes: the design system behind a point of sale
πŸ“°

One set of CSS tokens, two themes: the design system behind a point of sale

DEV Community: cssΒ·Zohaib AhmadΒ·about 8 hours ago
#YINbG7yV
#devtocss#devto#dev#primary#dark
Reading 0:00
15s threshold

A point of sale is used for eight hours straight, often in a bright shop and sometimes in a dim one. So Tilly POS needed a calm interface, a real dark mode, and β€” because I'm one developer β€” a way to get both without writing every style twice.

The answer is boring and it works: design tokens as CSS custom properties, and components that only ever use tokens.

Tokens: names for decisions, not colours

:root , [ data-theme = "light" ] { --bg : #f8fafc ; --surface : #ffffff ; --surface-muted : #f1f5f9 ; --border : #e2e8f0 ; --ink : #0f172a ; --ink-muted : #475569 ; --primary : #4f46e5 ; --primary-hover : #4338ca ; }

[ data-theme = "dark" ] { --bg : #020617 ; --surface : #0f172a ; --surface-muted : #1e293b ; --border : #1e293b ; --ink : #f1f5f9 ; --ink-muted : #94a3b8 ; --primary : #818cf8 ; --primary-hover : #a5b4fc ; }

Enter fullscreen mode

Exit fullscreen mode

The names describe what the colour is for β€” background, surface, ink, primary β€” never what it looks like .…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.