Lab · OzzyOS
How colour works in my design system
Colour in OzzyOS is built in three layers: base, semantic and component. Each layer only talks to the one below it. That's what lets a client swap in their own brand, or a page switch to dark mode, without anyone touching component code.
- 01 · Base
color.cobalt.10#1D2E3DEvery colour the brand owns, named by what it looks like. Never used in UI code. - 02 · Semantic
--oz-brand-primarycobalt.10 in light, cream in darkNamed by job. The same names in light and dark; each mode points them at different base colours. - 03 · Component · coming soon
--oz-button-bg→ --oz-brand-primaryNamed by part. Lets one component change without touching the rest of the system.
Base: what the colours look like
The base layer is the raw palette, and these are the only tokens named after what a colour looks like: cream, sand, cobalt.30, gold. Nothing in a component uses them directly. If a button said "cobalt", every client brand would have to be blue.
The base colours for OzzyOS come from OZARIN, my blog and podcast. The idea behind it is "heavy metal, soft edges". The name is a nod to Ozzy Osbourne, the Prince of Darkness. In practice:
- Midnight cobalt does the work. Text, primary buttons and dark surfaces are a deep blue rather than black. It reads as black at a glance, with more depth on screen.
- Cream is the background. It's softer than pure white for long reading, and still gives 17.5:1 contrast with midnight text.
- Gold is the spotlight. It's used once per view, for the thing that matters most: an upgrade, a "new" badge, the mascot. It's never text on a light surface, because gold on cream is only 2.2:1.
- Status colours are functional, not on-brand. Warning is a clear yellow, error is red, success is green. Warning started as burnt orange, but beside the error red the two were almost the same, so it moved to yellow.
- Cream#FCF9F2Page
- Paper#F8EFDECards
- Sand#EFD6ACHighlight
- Midnight#0D151CText, dark page
- Cobalt 10#1D2E3DPrimary
- Cobalt 30#3D556ALinks, focus
- Cobalt 40#4C6981Muted text
- Cobalt 50#56718BTertiary
- Cobalt 70#89A0B6Muted on dark
- Gold#DCA239Spotlight
- Yellow#F5C518Warning
- Red#B3261EError
- Green#2E7D5BSuccess
Semantic: what the colours are for
The semantic layer names colours by job: --oz-surface-bg, --oz-fg-muted, --oz-brand-primary, --oz-status-warning. This is the layer every component and stylesheet uses.
Two rules keep it honest:
- No colour words. A third party replacing the brand fills in the same names with their own values. A token called
surface-sandwould be wrong the moment someone else's brand used grey. - No mode words. Light and dark use exactly the same names. Each brand has a light file and a dark file, and they only differ in values. A test fails the build if the two ever define different names.
Switch the preview below. Nothing in the markup changes: the same tokens just point at different base colours.
.oz-surface-strong🤘 Upgrade--oz-surface-bg | #FCF9F2 |
|---|---|
--oz-surface-raised | #F8EFDE |
--oz-fg-default | #0D151C |
--oz-fg-muted | #4C6981 |
--oz-fg-action | #3D556A |
--oz-brand-primary | #1D2E3D |
--oz-brand-spotlight | #DCA239 |
--oz-focus | #3D556A |
A few decisions are easier to see here than to describe:
- Primary flips in dark mode.
--oz-brand-primaryis cobalt in light and cream in dark, so the main button stays the strongest thing on the page either way. - Third-party widgets get their own primary. Date pickers and checkout widgets usually put white text on whatever "primary" you give them. White on cream is unreadable, so vendors get
--oz-brand-primary-vendor, which stays cobalt in both modes. - The focus ring changes colour. It's cobalt on light surfaces and gold on dark, so it passes 3:1 against whatever it sits on.
- Status depends on context. A banner uses the status fill and its own text colour. Inline error text uses
--oz-fg-erroron the page. A caution on a form field isn't a warning at all: it's helper text in the muted colour, beneath the label.
Checked on every build
Every build checks the semantic pairs that matter against WCAG AA, in every brand and both modes: text on each surface, text on each button and status fill, and the focus ring on each surface. It also checks that the warning and error fills stay far enough apart to tell from each other. If a new brand fails any of these, it doesn't build.
Component: coming soon
The third layer will name colours by component part, such as --oz-button-bg or --oz-input-border, each pointing at a semantic token. Today the button's CSS reads --oz-brand-primary directly, which is fine while there's one component.
Component tokens earn their place once there are more. A client could make their buttons a different colour from their links without changing what "primary" means everywhere else. A component could also be restyled without editing its CSS. I'll add this layer alongside the next set of components, and write it up here.
The tokens and the build are in the public repo, bryoz/ozzyos.