Theme Variables

Every CSS variable a theme file can set, with its default and its range

A theme file sets the theme variables below on :root, inside @layer sa.theme:

wwwroot/css/theme.css
@layer sa.theme {
  :root {
    /* Your theme variables go here */
  }
}

Set only the theme variables you want to change. The theme builder has a control for each theme variable, with the same range.

The package also contains the list of theme variables as JSON, at /_content/StellarAdmin.UI/stellar-admin.theme-variables.json. Tools can read it to get the theme variables of the version your app uses.

Essential variables

Most themes only set these theme variables.

VariableDefaultValuesMeaning
--sa-accentoklch(0.5 0.16 258)any colorBrand colour: primary actions, focus, selection, bold highlights.
--sa-neutral-hue2550 to 360Hue the greys lean toward.
--sa-neutral-chroma0.0060 to 0.04How much the greys lean (0 is pure grey).
--sa-radius6px0px to 24px, Pill (9999px)Control corners.
--sa-pills00 or 1Tags (badges, chips, the switch) are pills instead of following the radius.
--sa-relief00 (Flat), 1 (Raised), 2 (Tactile)Raised adds a shadow under buttons; tactile also adds a bottom edge, a hover lift, a pressed state and recessed fields.
--sa-elevation0.70 to 3Shadow strength: 0 flat, 1 soft, 2 or more floating.
--sa-density10.7 to 1.4Spacing and control sizes, not type: 0.75 dense to 1.25 roomy.
--sa-font-sans"Inter", ui-sans-serif, system-ui, sans-serifa font stack; the theme builder offers Inter, Geist, IBM Plex Sans, Figtree, Source Sans 3, Space Grotesk, Lexend, Archivo, SystemBody and control font.
--sa-font-headingvar(--sa-font-sans)a font stack; the theme builder offers Same as body, Fraunces, Space Grotesk, LexendTitles.

Color

You can write colors in any CSS color syntax. StellarAdmin.UI adjusts the accent's fills and text to meet the WCAG contrast ratio of 4.5:1, so the accent can be any lightness.

Some theme variables follow another theme variable, and have no default. Set them only when you want a different value in dark mode, or for the text on the accent.

VariableDefaultValuesMeaning
--sa-accentoklch(0.5 0.16 258)any colorBrand colour: primary actions, focus, selection, bold highlights.
--sa-accent-darkUnset: follows Accentany colorThe accent in dark mode.
--sa-on-accentUnset: follows Accentany colorText on accent fills, instead of the automatic black or white.
--sa-dangeroklch(0.58 0.22 27)any colorDestructive actions and errors.
--sa-danger-darkUnset: follows Dangerany colorThe danger colour in dark mode.
--sa-successoklch(0.6 0.15 150)any colorStatus colour for success.
--sa-warningoklch(0.72 0.16 70)any colorStatus colour for warnings.
--sa-infooklch(0.6 0.14 240)any colorStatus colour for information.
--sa-neutral-hue2550 to 360Hue the greys lean toward.
--sa-neutral-chroma0.0060 to 0.04How much the greys lean (0 is pure grey).
--sa-neutral-hue-darkUnset: follows Neutral hue0 to 360The neutral hue in dark mode.
--sa-neutral-chroma-darkUnset: follows Neutral tint0 to 0.04The neutral tint in dark mode.
--sa-accent-tint0.150 to 1How much the accent tints hover, selection and highlight washes.
--sa-surface-depth0.80 to 1Separation between the page and cards (0 is one flat surface).
--sa-nav-tint0.50 to 1The sidebar, from page colour to sunken.
--sa-line-strength10.75 to 2Dividers and control borders (below 0.75 acts as 0.75).

Shape and depth

VariableDefaultValuesMeaning
--sa-radius6px0px to 24px, Pill (9999px)Control corners.
--sa-radius-outerUnset: follows Radius0px to 32pxCard and dialog corners.
--sa-pills00 or 1Tags (badges, chips, the switch) are pills instead of following the radius.
--sa-outlines10 or 1Filled parts (buttons, badges, chips, the switch track) also draw an outline.
--sa-relief00 (Flat), 1 (Raised), 2 (Tactile)Raised adds a shadow under buttons; tactile also adds a bottom edge, a hover lift, a pressed state and recessed fields.
--sa-sheen10 or 1Solid buttons get a lit surface: a gradient, a top highlight, a darker edge and a pressed shadow.
--sa-stroke1px0px to 3pxBorder width.
--sa-elevation0.70 to 3Shadow strength: 0 flat, 1 soft, 2 or more floating.

Space and type

The density changes the spacing and the size of the controls, but not the size of the text. To change the size of the text, set the type scale.

Each font theme variable is a list of fonts. End it with the system fonts, and load the web font in your layout, as described in adding fonts.

VariableDefaultValuesMeaning
--sa-density10.7 to 1.4Spacing and control sizes, not type: 0.75 dense to 1.25 roomy.
--sa-type-scale10.8 to 1.2Text sizes.
--sa-font-sans"Inter", ui-sans-serif, system-ui, sans-serifa font stack; the theme builder offers Inter, Geist, IBM Plex Sans, Figtree, Source Sans 3, Space Grotesk, Lexend, Archivo, SystemBody and control font.
--sa-font-headingvar(--sa-font-sans)a font stack; the theme builder offers Same as body, Fraunces, Space Grotesk, LexendTitles.
--sa-font-monoui-monospace, "SFMono-Regular", Menlo, Consolas, monospacea font stack; the theme builder offers System, JetBrains Mono, IBM Plex Mono, Geist MonoCode.
--sa-kbd-fontUnset: follows Fontvar(--sa-font-mono) (Monospace)Keyboard keys.
--sa-weight-control500400 (400), 500 (500), 600 (600)Buttons, tabs, menu items.
--sa-weight-heading600400 (400), 500 (500), 600 (600), 700 (700)Titles.
--sa-leading-body1.51.3 to 1.8Line height of running text.

Section labels

These theme variables style the labels of menu sections and sidebar groups, and the headers of tables that use the section label style.

VariableDefaultValuesMeaning
--sa-section-label-fontinheritinherit (Body font), var(--sa-font-heading) (Heading font), var(--sa-font-mono) (Monospace)Section labels: menu labels, sidebar group labels, and column heads when they take the section label style.
--sa-section-label-textcalc(0.71875rem * var(--sa-type-scale))var(--sa-text-2xs) (11px), calc(0.71875rem * var(--sa-type-scale)) (11.5px), var(--sa-text-xs) (12px), var(--sa-text-sm) (14px)Section label text size.
--sa-section-label-weight500400 (400), 500 (500), 600 (600), 700 (700)Section label weight.
--sa-section-label-transformnonenone (As written), uppercase (Uppercase)Section label case.
--sa-section-label-tracking0em0em to 0.15emSection label letter spacing.

Structure

VariableDefaultValuesMeaning
--sa-footer-fill00 or 1Card footers sit on a tinted band.
--sa-footer-rule10 or 1Card footers have a divider above them.
--sa-dialog-footer-fillUnset: follows Card footer band0 or 1Dialog and sheet footers sit on a tinted band.
--sa-dialog-footer-ruleUnset: follows Card footer rule0 or 1Dialog and sheet footers have a divider above them.
--sa-column-head-label00 or 1Table column heads take the section label style.
--sa-column-head-fill10 or 1Table column heads sit on a sunken band.
--sa-column-head-casenonenone (As written), uppercase (Uppercase), var(--sa-section-label-transform) (As section labels)Table column head case.
--sa-column-head-fontinheritinherit (Body font), var(--sa-font-mono) (Monospace)Table column head font.
--sa-current-page-fill00 (Outline), 0.15 (Soft), 1 (Solid)The current page in pagination.

Buttons

VariableDefaultValuesMeaning
--sa-solid-destructive10 or 1Destructive buttons are solid instead of a soft tint.
--sa-filled-secondary10 or 1Secondary buttons have a sunken fill instead of a bordered surface.
--sa-link-decorationnonenone (No underline), underline (Underline)Link buttons at rest.
--sa-press-offset1px0px to 2pxHow far a button moves when pressed.

Focus

VariableDefaultValuesMeaning
--sa-focus-width3px1px to 4pxFocus ring width.
--sa-focus-offset0px0px to 4pxGap between the control and the ring.
--sa-focus-colorUnset: follows Accentany colorFocus ring colour.

On this page