Skip to Content
Neshel-UI
Configuration

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.

neshel.config.ts
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; system is reserved.
  • extends is required on named themes ("light" or "dark") and also sets their color-scheme. It is not allowed on light and dark.
  • Apply a theme with data-neshel-theme="sepia" on any element.

BuiltInThemeInput

Overrides for a built-in theme (light or dark).

BuiltInThemeInput
PropTypeDefaultDescription
colorsPartial<ThemeColors>——
extendsnever——

NamedThemeInput

A named theme that starts from a built-in base.

NamedThemeInput
PropTypeDefaultDescription
colorsPartial<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 = string

Colour 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.

Edit on GitHub

On this page