Foundations
Colors
Semantic color tokens and the Tailwind utilities that apply them.
Deft has no numbered color scale. A color is a semantic token, a CSS variable such as --bg-control or --fg-muted, and every palette gives it one value for the light theme and one for the dark theme. You apply a token with a Tailwind utility, so the same class is right in every theme, palette and accent.
Each row in the examples on this page is one token: a light and a dark swatch, then the token name, its utility and where it belongs. A swatch with Aa shows the token as text on the surface it is meant for. The hex value and the contrast ratio under a swatch come from the base palette.
Surfaces
Surfaces are the fills a screen is built from. Pick one by the role of the element, not by how light it looks.
- The page is
bg-default. Thebodyrule of the theme andShell.Rootboth use it. bg-insetsets an area apart by tone, without a border:Sidebar.Root,List.Root,Panel.Rootand the page behindStandalone.- Everything that floats is
bg-overlaywith a shadow from Elevation: menus, selects, comboboxes, popovers, tooltips, dialogs, drawers, toasts and the action bar. bg-scrimcovers the page behindDialog.Content,Drawer.Contentand the sidebar when it opens as a panel.bg-inverseflips the page colors and always goes withtext-on-inverse: a pressedChip.Root, theinversetone ofAvatar.Root.- Selection has two tokens.
bg-selectedmarks the current item, as inSidebar.Itemand a selectedWaterfall.Row.bg-accent-subtlemarks aTable.Rowwith theselectedprop, which is how a table shows checked rows.
Controls
A control changes its fill by one step on hover or keyboard highlight. Which step depends on whether it has a fill at rest:
| Control | Rest | Hover or highlight |
|---|---|---|
Default Button.Root, Chip.Root | bg-control | bg-control-pressed |
field variant of Button.Root, Select.Trigger, Combobox.Trigger | bg-field | bg-control-hover |
Ghost Button.Root, menu items, table rows, Sidebar.Item | none | bg-control-hover |
Input.Root and Textarea.Root rest on bg-control, or on bg-field in their field variant, and switch to bg-default while focused. Tag.Root, Kbd.Root, the neutral Badge.Root and Skeleton.Root use bg-control as a quiet fill with no hover state.
Use the field variant for a control that sits on bg-inset. The dashboard uses it for the buttons, inputs and selects inside List rows.
Text
Text has four steps of emphasis. Go down a step when the text matters less.
| Utility | Use | In components |
|---|---|---|
text-default | Content: names, values, titles. | Dialog.Title, Field.Label, Stat.Value, table cells |
text-secondary | Labels of controls at rest. They turn text-default on hover or when active. | Default and ghost Button.Root, Tabs.Tab, Sidebar.Item, Chip.Root |
text-muted | Supporting text. | Field.Description, Dialog.Description, Section.Description, Stat.Label |
text-subtle | Captions and hints that the reader can skip. | Table.Header, Sidebar.Caption, chart axes, line numbers of Code.Root |
The other text utilities are tied to one job:
text-iconcolors icons at rest. Controls apply it to nested Tabler icons, so you rarely set it yourself.text-placeholderis the placeholder ofInput.RootandTextarea.Root.text-on-accentis the text color onbg-accent, andtext-on-inversethe one onbg-inverse.text-accentis accent-colored text on a neutral orbg-accent-mutedsurface: the accentBadge.Root, the check of a selectedSelect.Item. The theme uses the same token for a plain<a>.
State
Deft has three states: success, warning and danger. Warning and danger have a muted fill, success has only a text color. There is no info color. Neutral messages use the neutral tone of Badge.Root and Callout.Root, which is bg-control.
How the fill and the text pair up:
| Where | Fill | Text |
|---|---|---|
Warning Badge.Root, title of a warning Callout.Root | bg-warning-muted | text-warning |
Danger Badge.Root, title of a danger Callout.Root | bg-danger-muted | text-danger-emphasis |
Danger Button.Root | bg-danger-muted | text-danger, text-danger-emphasis on hover |
Field.Error, Stat.Delta, danger Menu.Item | none | text-danger, text-warning, text-success |
- On a muted fill only the short label takes the state color. The body of a
Callout.Rootstaystext-default. - An invalid
Input.Root,Textarea.RootorOtpInput.Rootgets a 1pxring-danger. The message below it isField.Errorintext-danger. Dot.Rootcolors the dot and the label separately. Thesuccesstone has abg-successdot and atext-secondarylabel.
border-subtle, the last row of the example, is the hairline of bordered controls: the default and field Button.Root, Input.Root, OtpInput.Root and Metric.Card. Dividers between rows of a List use the same token.
Hues
A hue is a pair: bg-hue-<hue> for a tile and text-hue-<hue> for the glyph on it. Use the two together. Avatar.Root does it with its tone prop, which accepts every name in the exported hues array: red, orange, amber, green, teal, blue, violet and pink.
Hues label things, they do not report status. For status use the state tokens above.
Hues are gray in the dashboard
In the minimal palette and in every accent the eight hues share one neutral pair, so a violet avatar and a green one look the same there. Only the other palettes give each hue its own color. Never use a hue as the only way to tell two things apart.
Chart colors
Charts are drawn in neutral tones. Color is kept for what needs attention.
chart-lineis the series the chart is about.chart-line-mutedis a second series next to it, andchart-trendis a quiet background trend.Chart.LineandSparkline.Rootcall these tonesstory,mutedandtrend.chart-barfills neutral columns and bars, andchart-griddraws gridlines and the empty track of a meter.chart-warning,chart-dangerandchart-criticalmark severity.Meter.Distributiondraws its good, fair and poor parts withchart-bar,chart-warningandchart-danger.- The accent color enters the data only through the
tailprop ofChart.LineandSparkline.Root, which redraws the end of the line withstroke-accent. chart-ramp-1tochart-ramp-5are ordered steps. The dashboard colors consecutive releases along the ramp.chart-series-1tochart-series-5are for categories that must stay apart. The dashboard gives one to each of the five web vitals.
Chart tokens work with every color utility. Use stroke- and fill- inside an SVG and bg- for a legend swatch: the dashboard draws a vital with fill-chart-series-1 and marks it in the legend with bg-chart-series-1. Chart takes these class names through its series.
From token to utility
The theme registers tokens in five groups. The group decides which utilities exist for a name.
| Group in the theme | Utilities | Names |
|---|---|---|
--background-color-* | bg-* | default, inset, overlay, control, field, control-hover, control-pressed, selected, inverse, scrim, accent, accent-hover, accent-muted, accent-subtle, warning-muted, danger-muted, hue-<hue> |
--text-color-* | text-* | default, secondary, muted, icon, subtle, placeholder, accent, on-accent, on-inverse, success, warning, danger, danger-emphasis, hue-<hue> |
--border-color-* | border-* | subtle, field |
--ring-color-* | ring-* | control, field |
--color-* | All color utilities: bg-*, text-*, border-*, ring-*, fill-*, stroke-* | accent, ground, success, warning, danger, chart-* |
So bg-inset exists and text-inset does not, while accent works everywhere: ring-accent, fill-accent, stroke-accent.
A name can point at a different token in each group. bg-accent is accent-emphasis, the strong fill, and text-accent is accent-fg, the readable text color. bg-default is the page and text-default is the text on it.
Tokens outside the examples
| Token | Utility | Use |
|---|---|---|
bg-field | bg-field | Fill of the field variant of buttons, inputs, textareas and select triggers. |
border-field | border-field | Stronger hairline: a focused Input.Root or OtpInput.Root, a hovered Metric.Tab. |
border-field | ring-field | Outline of the field variant of Textarea.Root. |
fg-subtle | ring-control | Outline of an unchecked Checkbox.Root and of checkbox items in menus and comboboxes. |
accent-emphasis | ring-accent | Focus ring of buttons, checkboxes, switches, chips, tabs, rows and sidebar items. |
accent-emphasis | fill-accent, stroke-accent | Logo.Root and the tail of a chart line. |
bg-default | ring-ground, ring-offset-ground | Gap between an element and its ring: the offset of a focus ring, the outline of avatars in Avatar.Group. |
success-fg | bg-success | Dot of the success tone of Dot.Root. |
danger-fg | bg-danger, ring-danger | Dot of the error tone of Dot.Root, ring of an invalid control. |
The accent tokens are shown in Theming, and the ring and shadow colors of each shadow in Elevation.
Contrast
Tests check these pairs in every palette, every accent and both themes with getContrast:
| Text | On | Minimum |
|---|---|---|
fg-default, fg-secondary, accent-fg, success-fg | bg-default | 4.5:1 |
fg-muted | bg-inset | 4.5:1 |
fg-placeholder | bg-field | 4.5:1 |
fg-on-emphasis | accent-emphasis | 4.5:1 |
warning-fg | warning-muted | 3:1 |
danger-fg | danger-muted | 3:1 |
hue-<hue>-fg | hue-<hue>-muted | 3:1 |
fg-subtle and fg-icon are not in the list. Keep them for captions and icons, and use text-muted or stronger for text a user has to read.