Back to Memos

UI Kit (`components/ui`)

web/src/components/ui/README.md

0.30.02.8 KB
Original Source

UI Kit (components/ui)

shadcn/ui primitives ("new-york" style, zinc base, lucide icons, CSS variables). This folder is the single source of styling truth. Read this before adding a component or reaching for className on a kit component.

The one rule: use props, not className

Consumers style kit components through variant / size / shape props only — do not pass className to add colors, sizing, borders, or hover states.

  • Need a look that no prop provides, but it recurs? Add a variant here.
  • Need layout/positioning (margins, absolute)? Put it on a wrapper element.
  • The element is genuinely bespoke (data-driven background, glass/blur, a contextual one-off)? Don't fight the kit — use a raw HTML element with its own classes. It is not a kit component.

Color comes from the semantic OKLCH tokens documented in ../../themes/COLOR_GUIDE.md (--primary, --muted-foreground, --success, --warning, …). Never hardcode gray-500 / amber-50 palette classes.

Variant catalog

Componentvariantsize / shapeNotes
Buttondefault · destructive · outline · secondary · ghost · linksize: default · sm · lg · icon · icon-smicon-sm (size-6) is local — for dense/compact icon buttons. Auto-sizes unsized svg children to size-4.
Badgedefault · secondary · destructive · outline · warningshape: default · pillwarning + shape are local additions. pill = rounded-full.
Tabsvariant: segmented · underlineLocal component (not upstream shadcn). Context-based Tabs/TabsList/TabsTrigger, no Radix. underline relies on the consumer's own divider.
Dialogsize: sm · default · lg · xl · 2xl · fullLocal size variants + auto-focus prevention on open.
Selectsize: xs · sm · defaultLocal size prop on the trigger.
DropdownMenuitem: default · destructiveLocal destructive item variant + a sub-menu hover-delay hook.

Each cva component also exports its variant types, e.g. ButtonVariant, ButtonSize, BadgeVariant, BadgeShape, TabsVariant — use these instead of re-deriving VariantProps.

Layering (z-index tiers)

Defined once as Tailwind tokens in themes/default.css (--z-index-*) and used by the primitives — do not hardcode z-[60]-style literals:

UtilityValueUsed by
z-overlay50Dialog / Sheet overlay + content
z-dropdown60Select / DropdownMenu / Popover content
z-tooltip70Tooltip content + arrow

A dropdown inside a dialog needs z-dropdown (already the default) so it renders above the overlay; a tooltip sits above everything.