Modes
Light and dark, the two ways to switch them, and how to nest a dark band in a light page or a light panel in a dark one.
Silkware has two modes, light and dark, and every colour token has a value in each. A component never asks which mode it is in: it reads bg-background and gets the right value. This page explains the mechanism. For wiring a toggle into an application, see Dark mode.
Follows the page mode
className="dark"
data-theme="dark"
data-theme="light" inside a dark region
Two ways to set a mode
The dark values live under two selectors in app/globals.css, and the light values under three:
| Mode | Selectors |
|---|---|
| Light | :root, .light, [data-theme="light"] |
| Dark | .dark, [data-theme="dark"] |
.dark is the shadcn convention and what the theme provider in this repository sets on html. data-theme="dark" is the brand source's convention. Both work, on the root or on any element, and a subtree takes the tokens of its nearest ancestor that sets a mode.
The dark: variant follows the same attributes. A custom variant in globals.css matches .dark, [data-theme="dark"] and their descendants, and ignores a descendant of a forced-light region. So an upstream class such as dark:bg-input/30 works inside a dark band in a light page.
Nested regions
A dark band in a light page
Put data-theme="dark" (or className="dark") on the element. Everything inside resolves to dark values.
The always-dark field
The brand has a dark field, used for the footer and full-width dark bands, that is dark in both modes. Paint it with bg-field and put data-theme="dark" on its content, so text, surfaces and hairlines inside resolve to dark values. Text on it is text-field-foreground and its notes text-field-muted.
Bring an engineer to your company
The band is dark in a light page and in a dark page.
--field is ink in light and graphite (#1c1c1e) in dark, so the band also stays visible against a dark page.
A forced light region in a dark page
.light and [data-theme="light"] set the light values inside a dark region. Use them for a preview of a printed document, or for a panel that must stay light.
The one limit
A dark band nested inside a forced-light region that is itself inside a dark root does not get dark: classes. The tokens inside are still correct. Avoid three levels: paint the band with bg-field and put data-theme="dark" on its content.
Rules
Use tokens and let the mode follow. Never write bg-white, text-black or a grey from Tailwind's palette: they do not change, so they break in the other mode and in a client brand.
Four orders wait on suppliers.
Updated by the ERP at 09:40.
Use semantic tokens so the surface follows the mode.
Four orders wait on suppliers.
Updated by the ERP at 09:40.
Don’t hard-code a palette colour.