Themes
Built-in and named theme inputs, colour values and the theme selection attribute.
The themes key of neshel.config.ts overrides the built-in light and dark themes and adds
named themes. Theme colour inputs are partial: unspecified roles keep the values of the base.
import { defineConfig } from "@neshel-ui/config";
export default defineConfig({
themes: {
light: { colors: { primary: "#1d3f73" } },
dark: { colors: { primary: "#9fb8e6" } },
sepia: {
extends: "light",
colors: { background: "#f4ecd8", foreground: "#2b2118", surface: "#fbf5e6", surfaceForeground: "#2b2118" },
},
},
});- Theme names: lower-case kebab-case, 1–32 characters;
systemis reserved. extendsis required on named themes ("light"or"dark") and also sets theircolor-scheme. It is not allowed onlightanddark.- Apply a theme with
data-neshel-theme="sepia"on any element.
BuiltInThemeInput
Overrides for a built-in theme (light or dark).
| Prop | Type | Default | Description |
|---|---|---|---|
| colors | Partial<ThemeColors> | — | — |
| extends | never | — | — |
NamedThemeInput
A named theme that starts from a built-in base.
| Prop | Type | Default | Description |
|---|---|---|---|
| colors | Partial<ThemeColors> | — | — |
| extends(required) | "light" | "dark" | — | Built-in base; also determines the theme's color-scheme. |
ThemeColors
A complete colour map for one theme.
type ThemeColors = { readonly [R in ColorRole]: ColorValue; }ColorValue
A CSS colour: #rgb, #rgba, #rrggbb, #rrggbbaa, rgb(), rgba(), hsl(), hsla()
or oklch(). Only border may be translucent. Checked by the neshel CLI, not by types.
type ColorValue = stringColour syntax
Accepted: hex (#rgb, #rgba, #rrggbb, #rrggbbaa), rgb(), rgba(), hsl(), hsla(),
oklch(). Named colours (navy), var(), color-mix() and lab() are rejected
(unsupported-color-syntax). Alpha below 1 is only allowed on border. Out-of-sRGB oklch() values
produce a warning and are gamut-mapped for the contrast check only (the CSS keeps your value).
See the Theming guide for roles, contrast and the cascade.