@dain-os/ui
v0.10.0
Published
DainOS master design system: universal components shared across DainOS and client apps (PRD-094).
Readme
@dain-os/ui
The DainOS master design system: universal, themeable React components shared across DainOS and client apps. Ships compiled ESM plus the design-token CSS layers. Built for Tailwind v4 and React 19.
Install
npm install @dain-os/uiPeer dependencies you provide: react and react-dom (v19). react-hook-form
(v7) is an optional peer, needed only if you use the Form atom.
Tailwind v4 setup
@dain-os/ui ships compiled components that reference Tailwind utility classes
(bg-primary, inline-flex, and so on). Two things have to happen in your app's
Tailwind v4 stylesheet for those to render:
- Scan the package so Tailwind generates the utilities the components use.
- Import the token layers so those utilities resolve to real colours, radii, and motion values.
/* app.css (your Tailwind v4 entry) */
@import 'tailwindcss';
/* 1. Generate the utility classes the compiled components reference.
The path is relative to THIS file; adjust the depth to your node_modules. */
@source '../node_modules/@dain-os/ui/dist/**/*.js';
/* 2. Token layers, in this order. */
/* Raw design tokens (neutral black-and-white default). */
@import '@dain-os/ui/styles/tokens.css';
/* Optional client brand overlay: re-declare the token vars with your colours,
AFTER tokens.css so the cascade picks up your values. */
/* @import './my-brand-tokens.css'; */
/* Density modes (optional). Activate kiosk sizing with
<html data-density="kiosk">. Safe to import even if you never set it. */
@import '@dain-os/ui/styles/density.css';
/* Token-to-utility contract: maps the tokens above to Tailwind utilities. */
@import '@dain-os/ui/styles/theme.css';
/* Reduced-motion contract. MUST come after any brand overlay, because it
re-declares the motion duration tokens and relies on cascade order. */
@import '@dain-os/ui/styles/base.css';The four CSS layers:
| Layer | Subpath | What it carries |
|---|---|---|
| Tokens | @dain-os/ui/styles/tokens.css | Raw OkLCH colour, radius, shadow and motion tokens (the swappable, per-client layer) |
| Theme | @dain-os/ui/styles/theme.css | The @theme inline token-to-utility contract, motion utilities and keyframes |
| Base | @dain-os/ui/styles/base.css | The reduced-motion contract (clamps every motion token under prefers-reduced-motion) |
| Density | @dain-os/ui/styles/density.css | Kiosk density mode, activated by data-density="kiosk" on the root element |
Usage
Import from a layer barrel, or from a granular component subpath for the narrowest dependency:
// Layer barrel
import { Button, Card, Badge } from '@dain-os/ui/atoms';
// Granular subpath
import { Button } from '@dain-os/ui/atoms/button';
export function Example() {
return <Button>Get started</Button>;
}Available layers: @dain-os/ui/atoms, /molecules, /organisms, /layout,
/hooks. Each component and hook is also exposed at its own subpath (for
example @dain-os/ui/layout/page, @dain-os/ui/hooks/use-mobile).
React Server Components
@dain-os/ui is safe to use in React Server Component trees, including the
Next.js App Router. Client components (anything that uses hooks, context or
browser APIs, for example Dialog, Sidebar and Select) keep their
'use client' directive in the published build, on every import path: the
granular subpath, the layer barrel and the root barrel all preserve the client
boundary. You can import a client component straight into a server component
without a boundary error. Server-safe components such as Button carry no
directive, so they stay renderable on the server.
Versioning
0.x while the component surface is still settling. The published API may
change between minor versions until 1.0.0. Pin a version and bump
deliberately.
