Tokens and theme
Tokens are the named colors, sizes and waits that every piece of the design kit is drawn from. Your own styles can use them too and match the kit.
Every name starts with --dk-, so it never clashes with your page’s own names. Use one as you would any custom property, such as padding: var(--dk-space-4). The properties the kit leaves for a page to set, such as --dk-focus, and the layer a page puts its own rules in are on A page’s own palette.
Color
Each color has a role, such as text or the page itself, and a value in each theme, both shown whatever theme you are in. Choose by role, so text is --dk-fg and a card is --dk-surface, and it stays right in both themes. To change a role in every piece at once, set it again on your page’s root as one light-dark() that holds both themes, as A page’s own palette does.
--dk-bgThe page itselfLight#ffffffDark#121212--dk-surfaceA card on the pageLight#f5f5f5Dark#1e1e1e--dk-raisedWhat floats over the page and its cards, such as a menuLight#ffffffDark#2a2a2a--dk-fgTextLight#1a1a1aDark#f0f0f0--dk-mutedText that steps backLight#5c5c5cDark#a5a5a5--dk-lineThe lines between thingsLight#d9d9d9Dark#3a3a3a--dk-controlThe edge of a field or buttonLight#858585Dark#7d7d7d--dk-accentLinks and the one action a page leads withLight#1f4fd8Dark#8fb0ff--dk-on-accentText on the accentLight#ffffffDark#121212--dk-highlightWhat is chosen or pointed atLight#e3eafbDark#22305a--dk-successWhat went rightLight#1d7a3eDark#5cc28a--dk-success-bgThe background of a callout for what went rightLight#e8f5ecDark#15301f--dk-dangerWhat went wrongLight#b3261eDark#ff8a80--dk-danger-bgThe background of a callout for what went wrongLight#fbecebDark#3a1f1d--dk-warningWhat needs care before it goes wrong, such as stock running lowLight#8a5300Dark#f0b453--dk-warning-bgThe background of a callout for what needs careLight#fdf3e0Dark#3b2c12
What the tests check for Color
These are the design kit’s own tests for this part, by the file each is in. They come from the source on GitHub as it was when this page was built, so they can be newer than the version named in the footer. Each file name opens that file as it was then.
src/tokens.test.ts, without a browsere2e/sheets.spec.ts, in a browser
Contrast
Contrast is how far apart two colors are in brightness, written as a ratio. WCAG, the web’s accessibility guidelines, asks for 4.5 to 1 between text and its background and 3 to 1 for the edge of a control. Every pairing here meets that in both themes, so pair colors as they are paired here. In each theme’s grid the drawn color runs across the top and the ground it sits on down the side, in one order for both themes with the least to spare first, and a dash marks a pairing the kit never makes. The page shows both themes’ grids whatever theme you are in. The figures come from this version’s tokens and are rounded down, and the kit’s tests check each one before a release.
Contrast in the light theme, each ratio to 1, the least to spare first
| Ground | --dk- | --dk- | --dk- | --dk- | --dk- | --dk- | --dk- | --dk- |
|---|---|---|---|---|---|---|---|---|
| Needs | 3.00 | 4.50 | 4.50 | 4.50 | 4.50 | 4.50 | 4.50 | 4.50 |
--dk- | 3.06 | Not a pairing | 5.54 | 5.50 | Not a pairing | Not a pairing | Not a pairing | 14.44 |
--dk- | 3.28 | 4.78 | 5.95 | 5.90 | Not a pairing | Not a pairing | Not a pairing | 15.50 |
--dk- | 3.21 | Not a pairing | 5.82 | 5.77 | 5.69 | Not a pairing | Not a pairing | 15.16 |
--dk- | 3.35 | Not a pairing | 6.07 | 6.02 | Not a pairing | 5.74 | Not a pairing | 15.80 |
--dk- | 3.38 | 4.93 | 6.13 | 6.07 | 5.99 | 5.80 | Not a pairing | 15.96 |
--dk- | 3.69 | 5.37 | 6.68 | 6.62 | 6.53 | 6.32 | Not a pairing | 17.40 |
--dk- | 3.69 | 5.37 | 6.68 | 6.62 | 6.53 | 6.32 | Not a pairing | 17.40 |
--dk- | Not a pairing | Not a pairing | Not a pairing | Not a pairing | Not a pairing | Not a pairing | 6.62 | Not a pairing |
Contrast in the dark theme, each ratio to 1, the least to spare first
| Ground | --dk- | --dk- | --dk- | --dk- | --dk- | --dk- | --dk- | --dk- |
|---|---|---|---|---|---|---|---|---|
| Needs | 3.00 | 4.50 | 4.50 | 4.50 | 4.50 | 4.50 | 4.50 | 4.50 |
--dk- | 3.11 | Not a pairing | 5.20 | 5.99 | Not a pairing | Not a pairing | Not a pairing | 11.24 |
--dk- | 3.45 | 6.46 | 5.78 | 6.66 | Not a pairing | Not a pairing | Not a pairing | 12.49 |
--dk- | 3.66 | Not a pairing | 6.11 | 7.04 | 6.60 | Not a pairing | Not a pairing | 13.22 |
--dk- | 3.28 | Not a pairing | 5.48 | 6.31 | Not a pairing | 7.30 | Not a pairing | 11.85 |
--dk- | 4.04 | 7.57 | 6.76 | 7.79 | 7.30 | 9.01 | Not a pairing | 14.62 |
--dk- | 3.48 | 6.51 | 5.82 | 6.71 | 6.28 | 7.76 | Not a pairing | 12.59 |
--dk- | 4.55 | 8.50 | 7.60 | 8.76 | 8.20 | 10.13 | Not a pairing | 16.43 |
--dk- | Not a pairing | Not a pairing | Not a pairing | Not a pairing | Not a pairing | Not a pairing | 8.76 | Not a pairing |
What the tests check for Contrast
These are the design kit’s own tests for this part, by the file each is in. They come from the source on GitHub as it was when this page was built, so they can be newer than the version named in the footer. Each file name opens that file as it was then.
src/tokens.test.ts, without a browser
Sizes, type and motion
This section holds every size, type step and wait, then the shadows, the stack order, the scrim and the grounds. Sizes that should grow with the reader’s text size are in rem. Code inside a sentence is in em, so it matches the words around it. Borders, the focus ring and shadows are in px, since they stay the same size.
Spacing
Steps 1 to 3 space the parts inside a piece, such as a label and its field or the buttons in a row. Steps 4 to 6 pad a piece and set pieces apart, such as the inside of a card or the room above a page’s title. Steps 6 to 8 set a page’s own sections apart, step 6 on an explainer and step 7 on a content page, a band or a group of sections.
--dk-space-10.25rem--dk-space-20.5rem--dk-space-30.75rem--dk-space-41rem--dk-space-51.5rem--dk-space-62rem--dk-space-73rem--dk-space-84rem
Type
--dk-text-numeral is for a score read from across a table.
--dk-text-caption0.85rem--dk-text-small0.9rem--dk-text-body1rem--dk-text-lead1.1rem--dk-text-title1.25rem--dk-text-heading1.5rem--dk-text-display1.75rem--dk-text-numeral3.5rem--dk-text-code0.9em
Line heights, weights, tracking and faces
| Token | Value |
|---|---|
--dk-leading-tight | 1.2 |
--dk-leading-body | 1.5 |
--dk-weight-normal | 400 |
--dk-weight-medium | 500 |
--dk-weight-strong | 600 |
--dk-tracking-caps | 0.06em |
--dk-font-sans | system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif |
--dk-font-mono | ui-monospace, 'SF Mono', Menlo, Consolas, monospace |
Radius
The pill radius is set far larger than any tab or tag is tall, so their ends are always fully round.
Every radius
| Token | Value |
|---|---|
--dk-radius-small | 0.25rem |
--dk-radius | 0.375rem |
--dk-radius-large | 0.5rem |
--dk-radius-pill | 999px |
Motion and waits
The durations set how long the kit’s motion takes, such as a hover or a sheet arriving, and a reader who turns on reduced motion gets none. --dk-wait is a delay, not a motion. The kit waits that long before it shows something is busy, such as a busy button turning gray or a loading line appearing, so a fast answer shows nothing. Reduced motion and forced colors both keep it.
Every duration and wait
| Token | Value |
|---|---|
--dk-duration-short | 150ms |
--dk-duration-medium | 250ms |
--dk-wait | 400ms |
Sizes
They include the height of a field, the least size of anything a thumb presses, and the width of the page’s column and of a line of reading. The sizes worked out from other tokens or from the screen, such as the insets that keep a page clear of a phone’s edges, are folded under the table.
Every other size
| Token | Value |
|---|---|
--dk-ring-width | 2px |
--dk-ring-offset | 2px |
--dk-indicator-width | 2px |
--dk-field-height | 2.25rem |
--dk-field-inline | 0.75rem |
--dk-target | 2.75rem |
--dk-target-large | 3.5rem |
--dk-strip | 2.5rem |
--dk-strip-tools | auto |
--dk-measure | 34rem |
--dk-column | 72rem |
--dk-app-column | 28rem |
--dk-app-bar | 4rem |
--dk-app-body | 8rem |
--dk-dialog-width | 32rem |
--dk-icon-size | 1.25rem or 1.5rem |
Sizes worked out from other tokens or the screen
Every size worked out from other tokens or the screen
| Token | Value |
|---|---|
--dk-space-4-held | min(var(--dk-space-4), 16px) |
--dk-space-5-held | min(var(--dk-space-5), 24px) |
--dk-field-inline-held | min(var(--dk-field-inline), 12px) |
--dk-app-side | var(--dk-space-4-held) |
--dk-safe-top | env(safe-area-inset-top, 0px) |
--dk-safe-right | env(safe-area-inset-right, 0px) |
--dk-safe-bottom | env(safe-area-inset-bottom, 0px) |
--dk-safe-left | env(safe-area-inset-left, 0px) |
--dk-column-inset | max(0px, (100% - var(--dk-column)) / 2) |
--dk-app-inset | max(0px, (100vw - var(--dk-app-column)) / 2) |
--dk-band-left | calc(max(var(--dk-safe-left), var(--dk-column-inset)) + var(--dk-space-4)) |
--dk-band-right | calc(max(var(--dk-safe-right), var(--dk-column-inset)) + var(--dk-space-4)) |
--dk-card-inset | var(--dk-space-5) |
--dk-dialog-inset | var(--dk-space-5-held) |
--dk-flow-step | var(--dk-space-4) or var(--dk-space-3) or var(--dk-space-2) |
Shadows, stacking and grounds
Shadows lift a piece off the page. The stack order sets what sits over what, the bars under the toast and the skip link over everything. A ground is the background a container such as a panel or a dialog sets for what it holds. The layer a page puts its own rules in, and the properties it sets, are on A page’s own palette.
Every shadow, stack and ground
| Token | Value |
|---|---|
--dk-shadow-raised | 0 6px 24px light-dark(rgb(0 0 0 / 0.18), rgb(0 0 0 / 0.5)) |
--dk-shadow-resting | 0 1px 3px light-dark(rgb(0 0 0 / 0.12), rgb(0 0 0 / 0.4)) |
--dk-scrim | light-dark(rgb(0 0 0 / 0.4), rgb(0 0 0 / 0.6)) |
--dk-stack-pinned | 1 |
--dk-stack-raised | 2 |
--dk-stack-bar | 3 |
--dk-stack-toast | 4 |
--dk-stack-skip | 10 |
--dk-ground | var(--dk-raised) or var(--dk-surface) |
--dk-ground-step | var(--dk-surface) or var(--dk-bg) |
What the tests check for Sizes, type and motion
These are the design kit’s own tests for this part, by the file each is in. They come from the source on GitHub as it was when this page was built, so they can be newer than the version named in the footer. Each file name opens that file as it was then.
src/tokens.test.ts, without a browser
How the theme is chosen
The kit’s theme script runs before anything is drawn, so a page never flashes the wrong theme. With scripts on, you choose Light, Dark or System next to Theme, at the top of the page. Your choice is saved, reaches your other tabs and is shared with the portfolio and every demo on jasonsdevspace.com, this site included. System, or no saved choice, follows your system’s setting. With scripts off, the page follows your system’s setting and does not use a saved choice.
What the tests check for How the theme is chosen
These are the design kit’s own tests for this part, by the file each is in. They come from the source on GitHub as it was when this page was built, so they can be newer than the version named in the footer. Each file name opens that file as it was then.
src/theme.test.ts, without a browsersrc/vite.test.ts, without a browsere2e/theme.spec.ts, in a browser