View as Markdown

Theming and Appearance

Theming and appearance

Theming with five color seeds, light and dark schemes, compact density, the font family, a tinted neutral ramp and region surfaces, plus grid lines, alternate rows, hover, row and header height, text wrap, custom icons and stable CSS hooks.

The theme is a small set of inputs on ThemeProvider: five semantic color seeds and a color scheme, plus four optional settings: density, fontFamily, a neutral tint and region surfaces. Every other value is derived from them and written as --salmon-* custom properties, and every derived color keeps the contrast guarantees. There is no radius, spacing, type scale or token-table input: each setting is one value, not a table.

interface SalmonThemeInput {
  colors?: { primary?; success?; warning?; danger?; info? }; // hex seeds
  colorScheme?: 'light' | 'dark' | 'auto';
  density?: 'default' | 'compact';
  fontFamily?: string;
  neutral?: { hue?: number; chroma?: number };
  surfaces?: { sidebar?; appBar?; tableHeader? }; // hex or 'primary'
}

Color seeds

ThemeProvider takes primary, success, warning, danger and info as opaque hex colors. Each seed becomes a tonal scale; neutrals, surfaces, borders, hover, selection and the focus ring are derived from it, so a seed cannot break the contrast guarantees: at least 7:1 for body text, 4.5:1 for secondary text and 3:1 for borders, focus ring and selection in both schemes. Invalid seeds (named colors, alpha, oklch(), CSS variables) fall back to the default with a development warning.

import { ThemeProvider } from '@salmonui/core/theme';
import { ThemeStyle } from '@salmonui/core/server';

const theme = { colors: { primary: '#0f766e', danger: '#be123c' }, colorScheme: 'auto' } as const;

<ThemeStyle theme={theme} />
<ThemeProvider theme={theme}>
  <DataGrid aria-label="Orders" data={orders} columns={columns} />
</ThemeProvider>

The scheme is light, dark or auto (follows prefers-color-scheme). ThemeStyle emits the scope's variables server-side as a hoisted, deduplicated <style>, so server-rendered pages paint in the right colors before hydration; the default theme ships precompiled in @salmonui/core/styles.css. Application CSS may read the --salmon-* variables but not set them.

Theme colors and contrast

Open demo

The five semantic color seeds and the color scheme are the whole theme input; the derived palette keeps text, border, focus and selection contrast for any seed, checked live below the grid.

Order
Customer
Priority
Amount
Shipped
ORD-10000
Hana Sato
Normal
$275.83
ORD-10001
Bao Nguyen
Normal
$378.00
ORD-10002
Goran Petrov
Normal
$285.60
ORD-10003
Farah Aziz
Normal
$12.60
ORD-10004
Goran Petrov
Normal
$649.00
ORD-10005
Bao Nguyen
Normal
$279.30
ORD-10006
Bao Nguyen
High
$133.00
ORD-10007
Elif Kaya
Normal
$1,419.00
ORD-10008
Elif Kaya
High
$903.00
ORD-10009
Bao Nguyen
Normal
$89.25
ORD-10010
Ines Duarte
Normal
$519.20
ORD-10011
Chen Wei
Normal
$47.60
ORD-10012
Farah Aziz
High
$47.18
ORD-10013
Hana Sato
High
$12.60
ORD-10014
Hana Sato
Low
$1,044.90
ORD-10015
Aiko Tan
Normal
$151.20
ORD-10016
Dewi Lestari
High
$50.40
ORD-10017
Hana Sato
Normal
$133.00
ORD-10018
Bao Nguyen
Low
$39.90
ORD-10019
Farah Aziz
Normal
$438.60
PairRatioMinimumResult

Density

density: 'compact' tightens every control and Data Grid row; 'default' is the regular size. Density does not replace the component size prop: each size has a default and a compact metric set, so size picks the step and density picks the set.

size default: height, inline padding compact: height, inline padding
sm 24px, 8px 20px, 6px
md 32px, 12px 28px, 10px
lg 40px, 16px 36px, 14px
  • Buttons, text fields, selects, comboboxes, date and time pickers, tags and every other single-line control follow the matrix. Menu, listbox, tree view and navigation items, pager buttons, toolbars and icon buttons use the md height; tabs are 4px taller than it.
  • The Data Grid default rowHeight / headerHeight are 36 / 40 px at default and 32 / 36 px at compact, and cell and header text is 13px instead of 14px (Tree Grid and Pivot Table render through the same cells). An explicit rowHeight or headerHeight prop always wins.
  • Spacing, radius, type scale and icon sizes stay the same: compact is tighter controls and rows, not a different layout.
  • A nested ThemeProvider that does not set density inherits it, so one setting at the root covers the whole application, and a compact panel inside a default page is one nested provider.

The metrics are CSS variables (--salmon-control-height-sm|md|lg, --salmon-control-padding-sm|md|lg, --salmon-font-size-cell) that the default theme does not emit: components read them with the default value as a fallback, so an application that never sets density pays nothing. Application CSS reads them the same way, for example min-block-size: var(--salmon-control-height-md, 32px).

Theme density

Open demo

The same buttons, text field, select, date picker, tabs and Data Grid under density default and compact side by side, with the measured control, row and header heights.

density: 'default'

11242026
Recent orders.
Order
Customer
Amount
ORD-10000
Dewi Lestari
$7.86
ORD-10001
Aiko Tan
$94.35
ORD-10002
Goran Petrov
$137.70
ORD-10003
Goran Petrov
$210.90
ORD-10004
Hana Sato
$35.70
ORD-10005
Hana Sato
$649.00

Measuring…

density: 'compact'

11242026
Recent orders.
Order
Customer
Amount
ORD-10000
Dewi Lestari
$7.86
ORD-10001
Aiko Tan
$94.35
ORD-10002
Goran Petrov
$137.70
ORD-10003
Goran Petrov
$210.90
ORD-10004
Hana Sato
$35.70
ORD-10005
Hana Sato
$649.00

Measuring…

Font family

fontFamily sets --salmon-font-sans, the family every component uses. The value is a CSS font-family list. The application loads the font itself (with @font-face, a font service or next/font), because Salmon UI ships no font files; end the list with a system fallback so text renders before the font arrives.

const theme = { fontFamily: 'Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif' };

Only letters, digits, spaces, commas, quotes, dots, hyphens and underscores are accepted. Anything else (a semicolon, braces, url()) is rejected with a development warning and the system stack is used. Unset, a nested scope inherits the enclosing scope's font and the root uses the system stack. The type scale (sizes, weights, line heights) does not change.

Neutral tint

Neutrals (surfaces, borders, text, hover) are near-achromatic by default, leaning slightly toward the primary hue. neutral tints the whole ramp:

  • hue in degrees (any number, taken modulo 360). Unset, the primary hue.
  • chroma in OKLCH, clamped to [0, 0.04] so neutrals stay neutral.

neutral: { chroma: 0.032 } with a teal primary such as #0e4d5c gives blue-green grays for text, borders and the page background. The tinted ramp goes through the same contrast pickers as the default one, so body text, secondary text, borders, the focus ring and selection keep 7:1, 4.5:1 and 3:1 in both schemes whatever the tint.

Surfaces

surfaces gives three application regions their own background with a derived foreground:

Surface Region The attribute comes from
sidebar The SidebarLayout panel and the navigation inside it SidebarPanel
appBar The application's top bar Your <header>
tableHeader The Data Grid header (also Tree Grid and Pivot Table) The grid header

Each value is a hex color, or 'primary' for the resolved primary seed. The seed is used as is in both color schemes; the theme derives the rest of the region's colors from it:

Role Derived as
Foreground Near-white on a dark seed, near-black on a light one: at least 7:1 against the background and 4.5:1 against hover and selected
Muted text The step closest to the background that keeps 4.5:1 (group headings, secondary text, placeholders)
Hover, selected The seed moved in lightness, with the foreground still readable on them
Border A divider step toward the foreground
Focus ring, accents The theme focus ring and primary accents when they keep 3:1 on the seed, else the foreground

So a sort arrow in a primary-colored header, or a checked checkbox or a selected item in a near-black sidebar, stays visible without any override.

The surface applies to the element carrying data-salmon-surface="sidebar", "app-bar" or "table-header": the theme emits one rule per set surface that paints the element and remaps the color variables for its subtree, so every component inside follows it. SidebarPanel and the Data Grid header carry the attribute already; put data-salmon-surface="app-bar" on your own top bar:

<header className="salmon-app-bar" data-salmon-surface="app-bar">…</header>

Without the surface in the theme the attribute matches nothing and costs nothing. Overlays opened from inside a surface (menus, popovers, date pickers) are portaled out of it and keep the regular overlay colors.

For custom navigation markup, each set surface also exposes its derived colors on the theme scope:

Variable Meaning
--salmon-surface-<name>-bg, -fg, -muted Background, text, secondary text
--salmon-surface-<name>-hover Item hover background
--salmon-surface-<name>-selected-bg, -selected-fg Selected item background and text
--salmon-surface-<name>-border Dividers

with <name> one of sidebar, app-bar and table-header:

.app-nav a { color: var(--salmon-surface-sidebar-fg); }
.app-nav a:hover { background: var(--salmon-surface-sidebar-hover); }
.app-nav a[aria-current='page'] {
  background: var(--salmon-surface-sidebar-selected-bg);
  color: var(--salmon-surface-sidebar-selected-fg);
}
.app-nav h2 { color: var(--salmon-surface-sidebar-muted); }

Reading these variables is supported; setting them is not. A nested ThemeProvider that does not set surfaces inherits the enclosing scope's surfaces. For a region that should be fully in the dark scheme (every role, not only its background), wrap it in a nested ThemeProvider with colorScheme: 'dark' instead.

Theme surfaces

Open demo

A SidebarLayout with a near-black sidebar surface, a white app bar surface and a primary-colored Data Grid header, on a teal-tinted neutral ramp, all from one theme object.

Olivia
Order
Customer
Product
Amount
ORD-10000
Jun Park
Oolong tea
$108.38
ORD-10001
Bao Nguyen
Grinder
$767.55
ORD-10002
Dewi Lestari
Green tea
$87.88
ORD-10003
Goran Petrov
Grinder
$245.10
ORD-10004
Hana Sato
Espresso beans
$16.65
ORD-10005
Farah Aziz
Filter beans
$28.00
ORD-10006
Goran Petrov
Oolong tea
$126.23
ORD-10007
Dewi Lestari
Grinder
$122.55
ORD-10008
Aiko Tan
Filter beans
$142.80
ORD-10009
Aiko Tan
Kettle
$184.97
ORD-10010
Farah Aziz
Espresso beans
$158.17
ORD-10011
Bao Nguyen
Filter beans
$59.50
ORD-10012
Farah Aziz
Oolong tea
$109.01
ORD-10013
Dewi Lestari
Kettle
$778.80
ORD-10014
Aiko Tan
Kettle
$61.66
ORD-10015
Dewi Lestari
Pour-over kit
$415.80
ORD-10016
Farah Aziz
Oolong tea
$25.50
ORD-10017
Ines Duarte
Green tea
$70.76
ORD-10018
Chen Wei
Green tea
$15.73
ORD-10019
Goran Petrov
Pour-over kit
$319.20

Theme like an admin template

A compact, teal-tinted admin layout with a dark sidebar, a white top bar and a primary-colored table header is one theme object:

import type { ReactNode } from 'react';
import { ThemeProvider, type SalmonThemeInput } from '@salmonui/core/theme';
import { ThemeStyle } from '@salmonui/core/server';
import { SidebarLayout, SidebarMain, SidebarPanel } from '@salmonui/navigation/sidebar-layout';

const theme: SalmonThemeInput = {
  colors: { primary: '#0e4d5c', success: '#0c8f54', warning: '#d4690b', danger: '#d62f23', info: '#0e4d5c' },
  density: 'compact',
  fontFamily: 'Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
  neutral: { chroma: 0.032 },
  surfaces: { sidebar: '#192225', appBar: '#ffffff', tableHeader: 'primary' },
};

export function AdminShell({ children }: { children: ReactNode }) {
  return (
    <>
      <ThemeStyle theme={theme} />
      <ThemeProvider theme={theme}>
        <SidebarLayout style={{ blockSize: '100dvh' }}>
          <SidebarPanel navigation aria-label="Main navigation">…</SidebarPanel>
          <SidebarMain render={(props) => <main {...props} />}>
            <header className="salmon-app-bar" data-salmon-surface="app-bar">…</header>
            {children}
          </SidebarMain>
        </SidebarLayout>
      </ThemeProvider>
    </>
  );
}

The sidebar, the app bar and every Data Grid header pick up their surfaces from the attributes; controls and grid rows are compact; text uses Inter once the application loads it.

Design notes

One theme, branded through the seeds

Salmon UI ships one neutral flat theme with automatic light and dark schemes, branded through the seeds; each extra theme would be a surface whose contrast and layout must be guaranteed separately. Pick the seeds closest to the palette in use. High Contrast users get the operating system's forced-colors mode, which the grid supports with system colors (see Accessibility).

Customizing the theme

The five seeds and colorScheme, plus density, fontFamily, neutral and surfaces, are the whole customization surface, and the demos above are the preview. Set the seeds to your brand's primary and status colors.

Size modes

The theme's density is the size mode: 'compact' makes rows 32px and headers 36px with 13px text (see Density). Row and header heights also stay available as grid layout props for any other size: set rowHeight and headerHeight on the DataGrid (the "Row size" control below); an explicit prop wins over the density.

Data Grid appearance

  • gridLines: 'default', 'both', 'horizontal', 'vertical' or 'none'.
  • striped (alternate row shading) and highlightOnHover, both default true.
  • A fixed rowHeight (default 36 px, 32 px at compact density), or a per-row getRowHeight function, and headerHeight per header level (default 40 px, 36 px at compact density).
  • textWrap: 'header', 'content' or 'both' (true) wraps text instead of truncating it. Content wrap needs measured rows: set estimatedRowHeight (see Virtualization).
  • className and style on the grid, and attributes on cells and headers, merge after the system classes. classNames and styles take one entry per part: root, toolbar, header, headerCell, body, row, cell, footer, pager, groupDropArea, groupCaption, detailRow, columnMenu, contextMenu, filterMenu, editor (the wrapper of each inline or dialog cell editor), empty and loading.
  • The root carries .salmon-data-grid and each part a .salmon-data-grid-<part> class (.salmon-data-grid-cell, .salmon-data-grid-header-cell, .salmon-data-grid-row); BEM __ marks only a sub-element (.salmon-data-grid-toolbar__more). These classes and the data-* state attributes are stable within a major version. Style parts through classNames / styles; targeting the classes directly is permitted but, like any visual override, unsupported.
  • Every Salmon UI rule is in the salmon cascade layer, so your own unlayered CSS overrides it whatever the specificity or the import order: .orders .salmon-data-grid-cell { padding-inline: 4px } wins without !important. If your app uses cascade layers, order salmon before importing any Salmon UI stylesheet, for example @layer reset, salmon, app;. The order in which you import the family stylesheets does not matter.

Grid lines, striping, row height and theme

Open demo

Grid line modes, alternate rows, hover highlight, fixed and conditional row heights, row and header size props in place of size modes, text wrap, className/style passthrough, and the colors-only theme with light, dark and auto schemes.

Order
Customer
Delivery priority
Note
Amount
Shipped
ORD-10000
Hana Sato
Normal
$75.60
ORD-10001
Aiko Tan
Normal
$324.50
ORD-10002
Farah Aziz
Normal
$70.30
ORD-10003
Farah Aziz
Normal
$774.00
ORD-10004
Elif Kaya
High
$33.30
ORD-10005
Elif Kaya
Normal
$154.00
ORD-10006
Ines Duarte
Normal
$109.01
ORD-10007
Chen Wei
Normal
Leave the parcel with the building reception if nobody answers the door.
$75.60
ORD-10008
Farah Aziz
Low
$94.35
ORD-10009
Farah Aziz
Normal
Call before delivery
$606.82
ORD-10010
Dewi Lestari
High
$102.00
ORD-10011
Dewi Lestari
Normal
Call before delivery
$493.24
ORD-10012
Farah Aziz
Normal
Gift wrap
$285.60
ORD-10013
Chen Wei
Normal
Leave the parcel with the building reception if nobody answers the door.
$292.05
ORD-10014
Ines Duarte
Normal
Call before delivery
$55.50
ORD-10015
Chen Wei
Normal
Gift wrap
$767.55
ORD-10016
Goran Petrov
Normal
$146.30
ORD-10017
Dewi Lestari
Normal
$210.90
ORD-10018
Farah Aziz
Low
$123.03
ORD-10019
Dewi Lestari
Normal
Call before delivery
$142.80

Icons

The grid's icons are built-in SVG images drawn by the grid stylesheet: they paint with the current text color, so they follow the theme, hover and active states, dark mode and forced-colors mode, mirror in right-to-left layouts, and add no markup to the page. There is no icon font; replace an icon with the icons prop. It is a component prop, not part of the theme:

import { ArrowUp, ArrowDown, Menu } from './my-icons';

<DataGrid
  aria-label="Orders"
  data={orders}
  columns={columns}
  sorting
  columnMenu
  icons={{
    sortAscending: <ArrowUp aria-hidden />,
    sortDescending: <ArrowDown aria-hidden />,
    columnMenu: <Menu aria-hidden />,
    filtered: null, // hide the filtered-column dot
  }}
/>
Name Where
sortAscending, sortDescending Sorted header and group chip
filter, filtered Header filter button; marker of a filtered column without one
columnMenu Header column menu button
groupByColumn, ungroup Header group toggle; group chip remove button
expanded, collapsed Group caption and detail row toggles
pagerFirst, pagerPrevious, pagerNext, pagerLast Pager buttons
submenu, check Menu items with a submenu; checked menu items
close, overflow, dragHandle Dialog and sheet close; toolbar overflow; row drag handle
  • A node replaces the built-in inside its button, which keeps its accessible name, so mark the icon aria-hidden. null hides an icon; a name left out keeps the built-in.
  • DataGridIconsProvider gives every grid below it the same icons (for example an application icon set); a grid's own icons merge over it, and child grids inherit them.
  • The icons are ordinary React nodes, so they render on the server and hydrate without a mismatch. Custom icons are not mirrored in right-to-left layouts; pass direction-aware icons if that matters.
  • Menu and toolbar items keep their own icon field.

Custom icons

Open demo

The grid draws built-in SVG icons with CSS; the icons prop replaces sort, filter, column menu, group, pager and menu icons with your own nodes, rendered on the server and hydrated without a mismatch.

Order
Customer
Amount
Country: France - 8 items
ORD-10024
Ines Duarte
$1,348.05
ORD-10089
Goran Petrov
$1,161.00
ORD-10181
Bao Nguyen
$1,102.95
ORD-10113
Chen Wei
$606.82
ORD-10128
Aiko Tan
$584.10
ORD-10183
Ines Duarte
$554.90
ORD-10130
Ines Duarte
$504.00
ORD-10062
Aiko Tan
$454.30

API reference

DataGridProps lists the appearance props, DataGridPart the classNames / styles keys and DataGridIcons the icon names; ThemeProvider and ThemeStyle take the theme and SalmonThemeInput lists its settings.