Styles
@xngui/styles@xngui/stylesCSS primitives → semantic roles → states. TypeScript token steps in @xngui/core.
Overview
Token Pipeline
Tokens flow from raw primitives to semantic roles your components consume. Each step builds on the previous — follow the order when authoring custom CSS.
Best path for most apps: primitives → semantic light & dark → scale & states. Add field and component layers only when you need them.
Primitives
primitives/--x-primary-500: oklch(0.58 0.12 212);Semantic Light
semantic/light.css--x-primary: var(--x-primary-500);Semantic Dark
semantic/dark.css.dark { --x-primary: var(--x-primary-400); }Scale
scale/--x-control-height: var(--x-size-height-md);Field
field.css.x-field[data-look="outline"] { … }States
states/.x-focusable:focus-visible { outline: … }Components
libs/components/**--x-button-height: var(--x-control-height);Dark semantic tokens pair with runtime appearance — see the Themes doc for light / dark / system mode.
Imports
Toggle optional entry points to build your stylesheet. Foundation is required; everything else layers on top for resets, Tailwind utilities, or icons.
styles.cssReset Optional CSS reset for a clean slate before design tokens.Optional CSS reset for a clean slate before design tokens. Not required when you already normalize base styles.Optional Tailwind Token Backed Bg Text And Border UtilitiesRecommended when you use Tailwind — token-backed background, text, and border utilities aligned with the design system.Optional Icons Icon font for icon componentsOptional icon font for icon components. Skip if you load icons another way or use inline SVG only.Optional
Related docs
Appearance mode, runtime palette switching, and CSS @import presets live on the Themes foundation doc.
Control scale
Control scale
Map size tiers and density to shared control height, padding, and radius tokens. Size and density types in core.
styles.css@import '@xngui/styles/scale';Density at size md
Padding and gap only — type size stays at md.
compactstandardcomfortableSize tiers at standard density
Height, type, and icon scale — orthogonal to density.
--x-size-height-xs--x-size-height-sm--x-size-height-md--x-size-height-lg--x-size-height-xlColors
All swatches on this page are live — they reflect palette {palette} in {mode} mode. Switch presets on the Themes doc or the navbar theme picker.
Palette CSS imports
Primitive palette overrides ship as optional CSS files under @xngui/styles/themes — one file per preset, imported after the foundation layer.
Use CSS @import when your brand palette is fixed. Use XPaletteService when users pick presets in the app.
CSS @import
Fixed palette at build time
- Zero JS — bundler ships only the theme file you import
- Best for production apps with a known brand color
Runtime service
User-selectable presets
- XPaletteService injects a :root block via <style id="x-palette">
- Persists the user’s choice across reloads
styles.css@import '@xngui/styles';@import '@xngui/styles/themes/nature/ocean';* Primitives only — pair with XThemeService for light dark semantics. *Semantic Roles
Theme slots per role — solid, text, border, hover, and subtle fills components consume.
Brand
--x-primary--x-primary--x-primary-foreground--x-primary-border--x-primary-hover--x-primary-subtleSecondary
--x-secondary--x-secondary--x-secondary-foreground--x-secondary-border--x-secondary-hover--x-secondary-subtleAccent
--x-accent--x-accent--x-accent-foreground--x-accent-border--x-accent-hover--x-accent-subtleNeutral
--x-neutral--x-neutral--x-neutral-foreground--x-neutral-border--x-neutral-hover--x-neutral-subtleSuccess
--x-success--x-success--x-success-foreground--x-success-border--x-success-hover--x-success-subtleWarning
--x-warning--x-warning--x-warning-foreground--x-warning-border--x-warning-hover--x-warning-subtleDanger
--x-danger--x-danger--x-danger-foreground--x-danger-border--x-danger-hover--x-danger-subtleInfo
--x-info--x-info--x-info-foreground--x-info-border--x-info-hover--x-info-subtlePrimitive Ramps
Primitive ramps swap with the active palette — OKLCH steps 50–950 for one-off tints and bindings.
--x-white--x-blackBrand
50100200300400500600700800900950Secondary
50100200300400500600700800900950Accent
50100200300400500600700800900950Neutral
50100200300400500600700800900950Success
50100200300400500600700800900950Warning
50100200300400500600700800900950Danger
50100200300400500600700800900950Info
50100200300400500600700800900950Surfaces Chrome
Neutral page chrome — grouped by surface role. Fills and foregrounds track the active palette and appearance mode.
Page
Base canvas and default body text
--x-background--x-foregroundCard
Elevated surfaces — containers, panels, and tiles
--x-card--x-card-foreground--x-card-border--x-card-hoverPopover
Floating layers — menus, dialogs, and tooltips
--x-popover--x-popover-foregroundMuted
De-emphasized fills and secondary copy.
--x-muted--x-muted-foregroundBorders & inputs
Dividers, control outlines, and focus rings
--x-border--x-input--x-ringSelection
Active and highlighted item chrome
--x-selected--x-selected-foregroundTypography
Type Scale
Font sizes with paired line heights — steps match the text size union.
- Aa — xs
--x-text-xs - Aa — sm
--x-text-sm - Aa — md
--x-text-md - Aa — lg
--x-text-lg - Aa — xl
--x-text-xl - Aa — 2xl
--x-text-2xl - Aa — 3xl
--x-text-3xl
Font Weights
Thin through black — each step maps to a --x-weight-* token.
- Aa — thin
--x-weight-thin - Aa — extralight
--x-weight-extralight - Aa — light
--x-weight-light - Aa — normal
--x-weight-normal - Aa — medium
--x-weight-medium - Aa — semibold
--x-weight-semibold - Aa — bold
--x-weight-bold - Aa — extrabold
--x-weight-extrabold - Aa — black
--x-weight-black
Spacing
Spacing Scale
4px-based gap and margin steps — same scale Tailwind uses.
Radius Shadow
Border Radius
Corner tiers from xs through full — use on cards, chips, and inputs.
Shadows
Elevation shadows from subtle chrome to floating overlays.
Z Index
Stacking Layers
Isometric stack — wider layers sit below; each step up narrows, shifts, and floats above the last.
- toast
--x-z-toastz-index 50 - fab
--x-z-fabz-index 40 - modal
--x-z-modalz-index 40 - overlay
--x-z-overlayz-index 30 - sticky
--x-z-stickyz-index 20 - dropdown
--x-z-dropdownz-index 10
Motion
Motion Composer
Preview runs much slower so you can study each curve — duration stays on your selection; recipe values stay exact.
transition: transform var(--x-duration-normal) var(--x-ease-in-out);200ms · cubic-bezier(0.4, 0, 0.2, 1)Duration Lanes
--x-duration-fastFast150ms--x-duration-normalNormal200ms--x-duration-slowSlow300ms
Easing Curves
--x-ease-inEase Incubic-bezier(0.4, 0, 1, 1)--x-ease-outEase Outcubic-bezier(0, 0, 0.2, 1)--x-ease-in-outEase In Outcubic-bezier(0.4, 0, 0.2, 1)
States
Live Samples
Click a selector chip to highlight its live sample below — same order, same state id.
- Disabled
[disabled], [aria-disabled="true"], [data-disabled], [data-state="disabled"], .x-disabledDisabled Usage - Readonly
[readonly], .x-readonlyVisible Not EditableReadonly - Invalid
[aria-invalid="true"], .x-invalidError Border RingInvalid Field - Loading
[aria-busy="true"], .x-loadingSpinner No Dimming - Focus
.x-focusable:focus-visibleShared Focus Ring - Selected
.x-selectedPressed Active Look
Tailwind
Role Utilities
Optional Tailwind bridge maps tokens to bg-*, text-*, and border-* utilities per semantic role.
Background
bg-primarybg-secondarybg-accentbg-neutralbg-successbg-warningbg-dangerbg-infobg-primary-300bg-secondary-400bg-danger-200bg-neutral-100Text
text-primarytext-secondarytext-accenttext-neutraltext-successtext-warningtext-dangertext-infotext-primary-600text-secondary-500text-danger-400text-neutral-700Border
border-primaryborder-secondaryborder-accentborder-neutralborder-successborder-warningborder-dangerborder-infoborder-primary-300border-accent-500border-danger-400border-neutral-300