Skip to Content
Neshel-UI
Configuration

@neshel-ui/config

Design tokens as CSS, the typed configuration schema and defineConfig.

@neshel-ui/config owns the design tokens. It ships two stylesheets and a small, browser-safe JavaScript entry with types and frozen contract data. It has no runtime dependencies and installing it injects nothing.

pnpm add @neshel-ui/config

Stylesheets

ExportContents
@neshel-ui/config/tokens.cssPlain CSS custom properties for every theme
@neshel-ui/config/tailwind.cssThe same tokens plus a Tailwind v4 @theme inline mapping
@neshel-ui/config/styles.css0.x alias of tailwind.css

Import one of tokens.css or tailwind.css. See CSS imports.

defineConfig

defineConfig is an identity function that gives neshel.config.ts full type checking — including exactness: unknown keys at any level, named themes without extends, or extends on light are compile-time errors (ExactConfig). The CLI validates the same rules at runtime.

neshel.config.ts
import { defineConfig } from "@neshel-ui/config";

export default defineConfig({
  version: 1,
  contrast: "warn",
  radius: { base: "0.75rem" },
  spacing: { unit: "0.25rem" },
  focus: { width: "2px", offset: "2px" },
  themes: {
    light: { colors: { primary: "#193767" } },
  },
  output: "./neshel.generated.css",
});

The file is executable, trusted project code evaluated by the CLI in Node — never in the browser, never fetched remotely.

Options

NeshelConfig

The neshel.config.ts schema, version 1.

NeshelConfig
PropTypeDefaultDescription
breakpointsBreakpointsInput—Custom responsive breakpoints shared by layout and typography.
contrastContrastPolicy—Custom-theme contrast diagnostics; defaults to "warn".
focus{ readonly width?: LengthValue; readonly offset?: LengthValue; }——
outputstring"./neshel.generated.css"Output file relative to the config file's directory. Default "./neshel.generated.css".
radius{ readonly base?: LengthValue; readonly sm?: LengthValue; readonly md?: LengthValue; readonly lg?: LengthValue; readonly xl?: LengthValue; }——
spacing{ readonly unit?: LengthValue; }——
themes{ readonly light?: BuiltInThemeInput; readonly dark?: BuiltInThemeInput; readonly system?: never; /** Named themes: lower-case kebab-case, 1–32 characters, `extends` required. */ readonly [name: string]: BuiltInThemeInput | NamedThemeInput | undefined; }——
typesstring"./neshel.generated.d.ts"Generated TypeScript declarations (written when breakpoints is set), relative to the config file's directory. Default "./neshel.generated.d.ts".
typography{ readonly families?: Partial<Record<FontRole, FontStack>>; /** Metrics of each role's primary font (Capsize format). */ readonly metrics?: Partial<Record<FontRole, FontMetrics>>; /** Metrics of local fallback fonts, adjusted to the primary font with Capsize. */ readonly fallbacks?: Partial<Record<FontRole, readonly FontMetrics[]>>; }——
version1—Configuration schema version; defaults to 1. Other values are rejected.
KeyMeaning
themesOverrides for light/dark and named themes — Themes
breakpointsCustom responsive breakpoints — Breakpoints
typographyFont families, metrics and fallbacks — Typography
radius, spacing, focusShape and spacing scale, focus ring
contrast"warn" (default) or "error" for custom-theme contrast diagnostics
output, typesGenerated stylesheet and declarations, relative to the config file

ExactConfig

Compile-time exactness for defineConfig: unknown keys at any level, named themes without extends, extends on light/dark, and a system theme become type errors.

ExactConfig
PropTypeDefaultDescription
breakpointsSection<T, "breakpoints">——
focusSection<T, "focus">——
radiusSection<T, "radius">——
spacingSection<T, "spacing">——
themesT extends { readonly themes: infer Th; } ? { [N in keyof Th]: ThemeCheck<N, Th[N]>; } : unknown——
typographyTypographyCheck<T>——

LengthValue

A CSS length: "0", or a number followed by rem, em or px (e.g. "0.75rem").

type LengthValue = string

ContrastPolicy

How contrast failures of custom themes are reported. neshel --strict always means "error".

type ContrastPolicy = "warn" | "error"

Validation

Configuration is validated by neshel validate and before every neshel generate: known keys only (with "did you mean" suggestions), colour syntax, alpha, gamut, contrast, lengths, font stacks, breakpoints, metrics and output paths. All diagnostics of a run are reported together — see Diagnostics.

Edit on GitHub

On this page