Skip to content
The design kit

A page’s own palette

This page brings its own colors and a narrower column, and puts its rules in a layer after the design kit’s, as a demo with a look of its own does.

The sheet this page adds, shown below, writes no rule over a kit class. Everything it changes, the strip and the footer too, it changes through the properties the kit reads. The colors and the column of this site’s other pages are the kit’s own. To see the other theme live, choose Light or Dark next to Theme, at the top of the page.

What this page sets

This is all the page adds to the kit beside the site’s own sheet, which every page of this site loads, and it loads after both of them.

CSS
/*
 * The page's own palette and column, as a demo with a look of its own sets them. The kit's layer
 * comes first and the page's after it, so the page's rules win over the kit's. Each color role
 * holds its light and dark value in one light-dark(), and the column is set on the root, where the
 * kit reads it.
 */
@layer dk, page;

@layer page {
    :root {
        --dk-accent: light-dark(#6a3fb5, #c3a8ff);
        --dk-on-accent: light-dark(#ffffff, #121212);
        --dk-highlight: light-dark(#efe9fb, #2d2448);
        --dk-focus: light-dark(#0f62c9, #6fb0ff);
        --dk-button-shadow: 0 2px 0 var(--dk-control);
        --dk-button-press: 0 2px;
        --dk-column: 64rem;
    }
}

Its palette

The page sets the accent, the text on it, the highlight and the focus ring, each as one light-dark() that holds both themes. Every piece reads its colors from those roles, so the markup is the same as on any other page. Press Tab to see the focus ring in the page’s own color.

A page that sets its own palette answers for its own contrast. These are the pairings the kit is meant for, measured in this page’s palette. In each theme’s grid the drawn color runs across the top and the ground it sits on down the side, and a dash marks a pairing the kit never makes.

Contrast of this page’s palette in the light theme, each ratio to 1, the least to spare first

Ground--dk-control--dk-success--dk-muted--dk-danger--dk-warning--dk-accent--dk-on-accent--dk-focus--dk-fg
Needs3.004.504.504.504.504.504.503.004.50
--dk-highlight3.11Not a pairing5.64Not a pairingNot a pairing5.92Not a pairingNot a pairing14.68
--dk-success-bg3.284.785.95Not a pairingNot a pairing6.25Not a pairingNot a pairing15.50
--dk-danger-bg3.21Not a pairing5.825.69Not a pairing6.11Not a pairingNot a pairing15.16
--dk-warning-bg3.35Not a pairing6.07Not a pairing5.746.37Not a pairingNot a pairing15.80
--dk-surface3.384.936.135.995.806.43Not a pairing5.3315.96
--dk-raised3.695.376.686.536.327.02Not a pairing5.8117.40
--dk-bg3.695.376.686.536.327.02Not a pairing5.8117.40
--dk-accentNot a pairingNot a pairingNot a pairingNot a pairingNot a pairingNot a pairing7.02Not a pairingNot a pairing

Contrast of this page’s palette in the dark theme, each ratio to 1, the least to spare first

Ground--dk-control--dk-success--dk-muted--dk-danger--dk-warning--dk-accent--dk-on-accent--dk-focus--dk-fg
Needs3.004.504.504.504.504.504.503.004.50
--dk-highlight3.50Not a pairing5.84Not a pairingNot a pairing7.11Not a pairingNot a pairing12.64
--dk-success-bg3.456.465.78Not a pairingNot a pairing7.03Not a pairingNot a pairing12.49
--dk-danger-bg3.66Not a pairing6.116.60Not a pairing7.43Not a pairingNot a pairing13.22
--dk-warning-bg3.28Not a pairing5.48Not a pairing7.306.66Not a pairingNot a pairing11.85
--dk-surface4.047.576.767.309.018.22Not a pairing7.4014.62
--dk-raised3.486.515.826.287.767.08Not a pairing6.3712.59
--dk-bg4.558.507.608.2010.139.24Not a pairing8.3216.43
--dk-accentNot a pairingNot a pairingNot a pairingNot a pairingNot a pairingNot a pairing9.24Not a pairingNot a pairing

Its column

The kit lines the strip, the header, the page and the footer up on one column, --dk-column, 72rem wide unless a page sets it. This page sets it to 64rem on its root, where the kit reads it, so on a wide screen everything here stands in further from the sides than on the other pages. A phone is narrower than either column, so it shows no change.

Its layers

The kit’s rules sit in a layer named dk. The page names its own layer after it, with @layer dk, page; before any rule of its own, so whatever it sets in page wins over the kit, however little its selector weighs. A rule outside any layer wins over both, as the site’s own sheet does.

The properties a page sets

Beyond the color roles, these are the properties the kit reads and leaves to a page, each unset until a page sets it, on its root or on a piece by a class of its own. This page sets --dk-focus, --dk-button-shadow and --dk-button-press, so its buttons sit on a shadow and move as they are pressed.

Every property a page sets

PropertyWhat it sets
--dk-button-grid-leastThe least width of a cell in a grid of buttons
--dk-button-grid-columnsThe columns a grid of buttons asks for, 3 unless set
--dk-focusThe focus ring and a control’s edge under a pointer, the accent unless set
--dk-button-shadowA shadow under a button at rest, none unless set
--dk-button-pressHow a held button moves, as a whole translate such as 0 2px, and where a toggle that is on or a button whose panel is open rests
--dk-field-measureThe widest a field, a row of fields or a callout in its form grows in a page, a band or a stack, the measure unless set
--dk-fields-leastThe width each field in a row of fields starts from, so two share a line only where both fit, 10rem unless set
--dk-band-roomThe room above and below a band, inside its ground
--dk-band-hero-pictureThe width of a hero’s picture beside its words
--dk-sections-leastThe least width of a section in a group of sections, 20rem unless set
--dk-table-groundThe ground under a table’s pinned column
--dk-table-pinned-sizeThe width of a table’s pinned column, 8rem unless set
--dk-panel-shadowThe shadow under a raised panel, the resting shadow unless set
--dk-row-picture-sizeThe width and height of a picture at a row’s start
--dk-tile-groundThe ground under a tile, the card’s on a page and the page’s in a panel
--dk-tile-shadowA shadow under a tile, none unless set
--dk-tile-leastThe least width of a tile in columns, 15rem unless set
--dk-stepper-digitsThe figures a stepper’s field keeps room for, 2 unless set