@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/configStylesheets
| Export | Contents |
|---|---|
@neshel-ui/config/tokens.css | Plain CSS custom properties for every theme |
@neshel-ui/config/tailwind.css | The same tokens plus a Tailwind v4 @theme inline mapping |
@neshel-ui/config/styles.css | 0.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.
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.
| Prop | Type | Default | Description |
|---|---|---|---|
| breakpoints | BreakpointsInput | — | Custom responsive breakpoints shared by layout and typography. |
| contrast | ContrastPolicy | — | Custom-theme contrast diagnostics; defaults to "warn". |
| focus | { readonly width?: LengthValue; readonly offset?: LengthValue; } | — | — |
| output | string | "./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; } | — | — |
| types | string | "./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[]>>; } | — | — |
| version | 1 | — | Configuration schema version; defaults to 1. Other values are rejected. |
| Key | Meaning |
|---|---|
themes | Overrides for light/dark and named themes — Themes |
breakpoints | Custom responsive breakpoints — Breakpoints |
typography | Font families, metrics and fallbacks — Typography |
radius, spacing, focus | Shape and spacing scale, focus ring |
contrast | "warn" (default) or "error" for custom-theme contrast diagnostics |
output, types | Generated 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.
| Prop | Type | Default | Description |
|---|---|---|---|
| breakpoints | Section<T, "breakpoints"> | — | — |
| focus | Section<T, "focus"> | — | — |
| radius | Section<T, "radius"> | — | — |
| spacing | Section<T, "spacing"> | — | — |
| themes | T extends { readonly themes: infer Th; } ? { [N in keyof Th]: ThemeCheck<N, Th[N]>; } : unknown | — | — |
| typography | TypographyCheck<T> | — | — |
LengthValue
A CSS length: "0", or a number followed by rem, em or px (e.g. "0.75rem").
type LengthValue = stringContrastPolicy
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.