Skip to main content
⌘K

Search

Search pages, pieces and blocks.

Day and Night

Night is never brighter than 300. Every piece reads its roles, the roles change, and nothing else has to know which theme it is in.

Switch
class on html
Change
circle, 400
Ceiling
300 #e2e2e1

In a real piece

The same card in both, side by side. This works because .light and .dark can be set on any part of the page.

Day

Beginner lesson, Ericeira
Sat 5 December, 9:00, 2 students
Confirmed
A surfer paddling out past a breaking wave, seen from above
TA

Night

Beginner lesson, Ericeira
Sat 5 December, 9:00, 2 students
Confirmed
A surfer paddling out past a breaking wave, seen from above
TA

How switching works

circle from the button, 400
  1. 1The toggle asks next-themes for the other themetheme-toggle.tsx, classes { light: "theme-light", dark: "dark" } on html
  2. 2Tokens swap, and no piece asks for the themeThe .dark block in globals.css re-points every role. No piece reads the theme in script; 36 files in src/components/ui add dark: classes, 106 in all, where a role alone falls short.
  3. 3The new theme grows as a circle from the buttondocument.startViewTransition, clip-path circle over --duration-theme 400 on --ease-even
  4. 4Reduced motion or no View Transitions: at onceTransitions are held off for one frame, so nothing fades through the change
  5. 5A part of the page can keep its own themedark: is (&:is(.dark *):not(.light *)), so .light inside Night brings Day back

The 300 ceiling

Night uses the scale from 975 up to 300 and stops. The number under a step is how many Night roles point at it. Day steps 50 to 250 are never used in Night.

Lightest Night valuesOKLCH LWhat it is
--foreground0.913foreground, primary, ring and chart-1 all stop at 300 #e2e2e1
--chart-20.845The second chart series
--destructive-ink0.820The lightest status ink, under the ceiling
--range0.801The Slider's filled part

Images and marks in Night

A surfer paddling out past a breaking wave, seen from above
A surfer paddling out past a breaking wave, seen from above
Photos keep their colour

No filter, no dimming. Avatar draws its edge with after:border-border, mix-blend darken in Day and lighten in Night, so a dark photo still has an edge.

Marks and icons invert

Icons and the Brand Mark take currentColor. On marks are Primary, so a Night Checkbox is a 300 square with a 975 check. The off Switch thumb turns muted-foreground.

A brand keeps its hue

.brand-sample carries a brand to Primary and the ring: #0f766e in Day, #5fb8ac in Night, lifted so it reads on #1f1f1e.

Do and don't

Payout sent
€1,240.00 to the account ending 4821.
DoNight from the tokens: a 975 page, 300 text and a 300 Primary. Quiet, and its text clears 4.5:1.
Payout sent
€1,240.00 to the account ending 4821.
Don'tPure black and pure white. The contrast is 21:1, it glares, and the card no longer sits on the page.

Rules

  1. 1Never write a colour for Night. Use the role; the .dark block does the rest.
  2. 2Nothing in Night is lighter than 300. If text looks dim, the surface is too light, not the text too dark.
  3. 3Check both themes. The pairs on the Colour page clear 4.5:1 for text and 3:1 for edges in Day and in Night; a new pair has to as well.
  4. 4A sample, a code block or a preview may pin its theme with .light or .dark. A page may not.