Skip to content
Dumb UI

Search Dumb UI

Jump to a page or component, or switch the style

Search Dumb UI

Jump to a page or component, or switch the style

Create a component

Write the component once. If it only reads tokens, it already works in Raw, Silk and Volume.

  1. Structure in TSX, material in CSS. Layout, semantic colors and geometry tokens (rounded-(--du-radius-control), h-(--du-h-md)) go in className. Borders, shadows, type, transforms and keyframes go in the material layer.
  2. Put data-slot after the props spread. Triggers with asChild pass their own slot down; the component must keep its own or it loses its material.
  3. Never branch on style. If a style needs a different geometry, add a token and give every style a value.
  4. No outline-none on focusable parts. Focus rings come from the base layer and each style tunes them.
src/components/ui/stat.tsx
// src/components/ui/stat.tsx
import * as React from "react"

import { cn } from "@/lib/utils"

function Stat({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      className={cn(
        // structure + semantic color + geometry tokens
        "grid gap-1 rounded-(--du-radius-surface) bg-card p-(--du-pad-surface)",
        className
      )}
      {...props}
      data-slot="stat" // after the spread: the slot always belongs to the component
    />
  )
}

export { Stat }
src/styles/dumb-ui.css
/* src/styles/dumb-ui.css, inside @layer components */
[data-slot="stat"] {
  border: var(--du-border-surface) solid var(--border);
  box-shadow: var(--du-shadow-surface);
}

Add an example file in src/examples (default export), then an entry in src/docs/components.ts. The page, preview, compare mode, search entry and registry item are generated from that entry. Optional: a props playground in src/docs/playgrounds.tsx.

src/docs/components.ts
// src/docs/components.ts
{
  slug: "stat",
  title: "Stat",
  description: "A single number with a label.",
  group: "Display",
  dependencies: [],
  registryDependencies: [],
  examples: [{ name: "stat-demo", title: "Stat" }],
  usage: { imports: `import { Stat } from "@/components/ui/stat"`, code: `<Stat>…</Stat>` },
}
pnpm test        # contract, contrast and component tests
pnpm registry    # rebuild public/r
pnpm build       # type check + static build