Skip to content

Design Pattern ​

Status: Active specification. The Nimi Design Pattern (P-DESIGN-*) defines cross-app visual conventions and interaction contracts.

The Nimi Design Pattern is maintained in @nimiplatform/kit/ui. It governs UI primitives, semantic design tokens, theme layering, and the shared visual and interaction contracts that every managed application follows.

Foundational Specifications ​

DimensionSpecification & Rule
Authoritative spec.nimi/spec/platform/ui-design-system.authority.yaml
Machine projectionconfig/platform-*.yaml
Managed consumersDeclared in each app's local Kit manifest
Allowed app ownershipComponent composition, local layout, accent pack selection, and product-specific visual identity
Disallowed app behaviorRedefining shared primitive families, inventing unmanaged token categories, or breaking platform contracts

Theme Pack Architecture (P-DESIGN-002) ​

All applications share a common visual foundation, while each app expresses its own brand identity through a single accent pack overlay.

LayerContent & Responsibility
Foundation schemeShared light and dark base schemes (nimi-light, nimi-dark)
Shared accent packDefault platform accent scheme (nimi-accent)
Consumer accent packApp-specific accent overlay declared in the app manifest

Managed applications import their theme stylesheets at the entry point:

css
@nimiplatform/kit/ui/themes/light.css
@nimiplatform/kit/ui/themes/dark.css
@nimiplatform/kit/ui/themes/<app>-accent.css   /* Exactly one accent pack */

Combining multiple accent packs or rendering an accent pack without the foundational base scheme is not supported.

Semantic Token Taxonomy (P-DESIGN-003) ​

Platform-wide semantic tokens are defined in config/platform-nimi-ui-tokens.yaml:

CategoryExample Usage
surfaceCard and background surface tones
textMulti-tier text hierarchy and opacity
actionInteractive button and action state tones
overlayModal and popover backdrop overlays
sidebarNavigation and sidebar backgrounds
fieldForm input fields, borders, and controls
statusInformational, success, warning, and error states
radiusCorner radius scale
spacingSpacing and margin scale
typographyFont families, size scales, and weights
strokeBorder stroke widths
elevationShadows and depth layers
motionAnimation durations and bezier easings
zLayer z-index scale
sizingStandard control dimensions
borderDivider and border tones
opacityGeneral opacity scale
focusKeyboard focus ring highlights
scrollbarCustom scrollbar tracks and thumbs
toggleSwitch and checkbox active states
materialMaterial textures and frosted glass (see Nimi UI Material)
backdropBackdrop gaussian blur gradients
ambientAmbient glow and atmospheric highlights

Every semantic token belongs to either the foundation layer or the accent layer, with concrete values generated from config/platform-nimi-ui-themes.yaml. Application code must not maintain parallel, unmanaged token registries.

Theme Scheme Contract (P-DESIGN-004) ​

DimensionContract Constraint
Resolved schemeEvaluates strictly to light or dark
Root variable ruleApps must not define parallel theme roots or private root variable systems outside the spec
Accent freedomAccent packs may freely express app-specific brand colors and emphasis styles
Accent constraintAccent packs must not override foundational base schemes or alter primitive structure

Visual Primitives Specification (P-DESIGN-005) ​

DimensionContract Constraint
Variant taxonomyDefined in config/platform-nimi-ui-primitives.yaml
ImplementationUses cva (Class Variance Authority) with Tailwind CSS utilities inside kit/ui
Interaction coreBuilt on accessible, unstyled Radix UI headless primitives
Token mappingBound via Tailwind @theme directives backed by generated CSS variables
ConsumptionConsumed through CVA variant props rather than scattered class selectors
Allowed app ownershipFreely composing exported Kit primitives
Disallowed app behaviorDeclaring custom CVA variants outside kit/ui for shared primitive families

No App-Local Primitive Redefinitions (P-DESIGN-006) ​

DimensionContract Constraint
Stylesheet restrictionsApp stylesheets must not define global override classes or conflicting Tailwind rules targeting shared primitives
Wrapper componentsApps may build local business wrappers to arrange layout and composition
Contract integrityLocal wrappers must preserve the visual and interaction contracts of shared primitives
Scoped overridesCustom styles may target only app-owned DOM nodes and private class names

No App-Local Token Overrides (P-DESIGN-007) ​

DimensionContract Constraint
Variable assignmentApp stylesheets must not reassign --nimi-* global CSS variables
Token sourceSemantic tokens are compiled exclusively from config/platform-nimi-ui-themes.yaml
Safe consumptionShared primitives and app components read tokens via var(--nimi-*)
Conflict avoidanceAvoid hardcoded color values or conflicting fallback tokens in local CSS

Deprecating Legacy Aliases (P-DESIGN-008) ​

Compiled accent packs emit standardized --nimi-* semantic tokens only. Legacy alias prefixes (--ot-*, --color-ot-*, --color-brand-*, --color-accent-*) are retired and must not be emitted or consumed as shared visual authority.

When apps need finer brand expression, they should pair standard semantic tokens with local color-mix(...) expressions rather than relying on private alias variables for core semantics such as surfaces, text, or focus states.

Shared Primitives Contract (P-DESIGN-010) ​

Shared UI primitives:

  • Are exported from @nimiplatform/kit/ui;
  • Build on Radix UI headless components for accessibility (including Dialog, Tooltip, ScrollArea, Select, Switch, Avatar, and Popover);
  • Reference --nimi-* semantic tokens through CVA variants and Tailwind utilities.

Managed app modules must use the following shell-level primitive families: surface, action, overlay, sidebar, field, status, scroll_area, toggle, and avatar. Apps may add lightweight business wrappers as long as the baseline visual and interaction contracts remain intact.

Typical Scenario: Adding an Accent Pack for a New App ​

When a new app needs its own brand accent:

  1. Declare the accent: Add app-owned accent values to the governed theme inputs so generation produces <app>-accent.css under @nimiplatform/kit/ui/themes/.
  2. Assign accent tokens: Set values for supported accent layer tokens while leaving foundation tokens untouched.
  3. Import the theme files: Import the base light/dark CSS and <app>-accent.css in the app entry module.
  4. Render the brand identity: The app presents its own visual accent while staying aligned with platform-wide accessibility and interaction contracts.

An accent pack only assigns values to existing standard tokens; it must not introduce unregistered private token prefixes.

Typical Scenario: Requesting a New Visual Variant ​

When an app needs a button style that existing primitives do not cover:

  1. Check the spec: Review config/platform-nimi-ui-primitives.yaml for supported variants.
  2. Respect boundaries: Do not patch or add custom CVA variants to the shared Button component inside app code.
  3. Choose a supported path: For a new shared-family variant, update its official Kit contract and implementation. App-local business composition may arrange existing primitives but cannot evade their contracts by renaming a wrapper.

Architectural Boundaries ​

  • Apps must not override or alter the contracts of shared primitives.
  • Apps must not assign values to --nimi-* CSS variables in local stylesheets.
  • Accent packs apply only to the accent token layer and must not modify foundation tokens.
  • Unmanaged global CSS must not target or pollute shared primitive selectors.

Specification Summary ​

ConcernSpecification Authority
Foundational architectureP-DESIGN-001
Theme layering modelP-DESIGN-002
Semantic token taxonomyP-DESIGN-003 + config/platform-nimi-ui-tokens.yaml
Scheme resolution contractP-DESIGN-004
Visual primitive systemP-DESIGN-005 + config/platform-nimi-ui-primitives.yaml
Local redefinition restrictionsP-DESIGN-006, P-DESIGN-007, P-DESIGN-008
Shared primitive contractsP-DESIGN-010

Source Basis ​

Documentation for Nimi — the installable, open-source, local-first personal AI product.