# brijr/ui

> A shadcn component registry built on UI SDK (`@ui-sdk/react`) and Tailwind CSS v4. Components copy into `components/ui` as framework-agnostic React 19 source.

## Quick start

Requirements: React 19+, `@types/react` 19.2.10+, Tailwind CSS v4, and an `@/*` import alias.

```bash
# 1. Initialize tokens, dependencies, and the @brijr registry namespace
npx shadcn@latest init https://ui.bridger.to

# 2. Add components by short name
npx shadcn@latest add @brijr/button @brijr/field @brijr/input @brijr/dialog
```

**Required CSS step (manual):** Add `@layer ui-sdk;` as line 1 of your global stylesheet, above `@import "tailwindcss";`, so app utilities always override UI SDK's runtime behavior rules:

```css
@layer ui-sdk;

@import "tailwindcss";
```

If `init` was skipped, register the namespace manually:

```bash
npx shadcn@latest registry add @brijr=https://ui.bridger.to/r/{name}.json
```

Inspect any component's exact source and props before using it:

```bash
npx shadcn@latest view @brijr/dialog
# or fetch https://ui.bridger.to/r/<name>.json
```

Once installed, also read `node_modules/@ui-sdk/react/docs/llms.txt` for primitive behavior details.

## Tokens and visual rules

Use semantic tokens only. Never hardcode hex/Tailwind palette colors (like `bg-neutral-100` or `text-gray-500`), raw durations (`duration-200`), raw shadows (`shadow-md`), or `transition-all`.

- **Surfaces:** `bg-background` (page), `bg-card` (discrete container), `bg-popover` (floating menu/popover/dialog), `bg-muted` (recessed area), `bg-secondary`, `bg-accent`.
- **Ink:** `text-foreground` (primary copy), `text-muted-foreground` (secondary/helper copy), `text-primary` / `text-primary-foreground`, `text-destructive`.
- **Chrome:** `border-border`, `border-input`, `ring-ring`. Focus uses `focus-visible:ring-3 focus-visible:ring-ring/50`.
- **Elevation:** `shadow-(--elevation-control)` (bordered controls), `shadow-(--elevation-popup)` (menus, popovers, tooltips, selects), `shadow-(--elevation-overlay)` (dialogs, sheets). Popups and overlays take **no** `border` — their elevation token draws the 1px edge and becomes a ring in dark mode.
- **Motion:** `duration-(--duration-state)`, `duration-(--duration-popup)`, `duration-(--duration-popup-exit)`, `duration-(--duration-overlay)`, `duration-(--duration-overlay-exit)`, `duration-(--duration-layout)`, paired with `ease-(--easing-state)`, `ease-(--easing-enter)`, `ease-(--easing-move)`. Name transitioned properties explicitly (e.g. `transition-[opacity,transform]`), never `transition-all`.
- **Typography & layout:** Sans-only (`font-sans`; `font-mono text-xs` only for code, IDs, commands). Use `text-lg font-medium tracking-tight` for the page title only; `text-sm` does body and muted copy. Build hierarchy from space, then color, then weight — size last.
- **Alignment & cards:** Left-align UI copy (empty states, cards, dialogs, alerts, buttons — never `text-center` on UI copy). Use `Card` only for discrete, repeatable surfaces; otherwise let spacing group content.

## Variants (closed sets — nothing else exists)

### Button

Variants: `default`, `secondary`, `outline`, `ghost`, `destructive`, `link`.
Sizes: `default` (36px), `xs` (28px), `sm` (32px), `lg` (40px), `icon`, `icon-xs`, `icon-sm`, `icon-lg`.

```text
Is the action destructive or hard to undo?
 ├── Yes -> variant="destructive"
 └── No
      ├── Single primary CTA on the view? -> variant="default" (one per view)
      ├── Secondary bordered action? -> variant="outline"
      ├── Low-emphasis or toolbar action? -> variant="ghost" (or "secondary")
      └── Inline text navigation? -> variant="link"
```

- Plain `<Button>` renders `type="button"`. Always pass `type="submit"` to submit a form.
- Async pending state: if `onClick` returns a Promise, the button enters `data-pending` automatically. For stable width, pass two leading spans: `<span data-show="idle">Save</span><span data-show="pending">Saving…</span>`.
- For navigation styled as a button, compose with `render`: `<Button render={<a href="/settings" />}>Settings</Button>`.

### Badge

Variants: `default`, `secondary`, `outline`, `ghost`, `destructive`. Wrap truncating text in a `<span>`. Icon-only badges need `role="img"` and `aria-label`.

### Alert

Variants: `default`, `destructive`.

### Toggle

Variants: `default`, `outline`. Sizes: `default`, `sm`, `lg`. A lone `Toggle` is not a form control — use `Checkbox` or `Switch` inside forms.

## Critical differences from Radix / stock shadcn

This kit is built on **UI SDK**, not Radix. Do not write Radix patterns.

| Mistake (Radix / stock shadcn) | Correct (`brijr/ui`) |
| --- | --- |
| `<DialogTrigger asChild><Button>Open</Button></DialogTrigger>` | `<DialogTrigger render={<Button />}>Open</DialogTrigger>` |
| `<Sheet><SheetContent side="left">` | `<Sheet side="left"><SheetContent>` |
| `<TooltipProvider>`, `<DialogPortal>`, `<PopoverAnchor>` | Remove them — popups render in the browser top layer |
| `<Button>Save</Button>` inside `<form>` | `<Button type="submit">Save</Button>` |
| `<Tabs>` without `defaultValue` in SSR | `<Tabs defaultValue="general">` (prevents hydration mismatch) |
| `<Accordion type="single">` or `type="multiple"` | Single by default; add `multiple`. Values are always arrays |
| `<DropdownMenuItem destructive>` | `<DropdownMenuItem variant="destructive">` |
| `<SelectLabel>` for the field label | `<SelectLabel>` is the group heading; `<SelectFieldLabel>` labels the select |

- **Placement props** (`side`, `align`, `sideOffset`) go directly on `*Content`.
- **State styling** uses data attributes: `data-open:`, `data-checked:`, `data-pressed:`, `data-disabled:`, `data-starting-style:`, `data-ending-style:`.
- **Server Components:** Every component renders from a Server Component. Add `"use client"` only in files that hold state or pass event handlers.
- **Forms:** Wrap controls in `Field` (`FieldLabel`, `FieldDescription`, `FieldError`) — it wires labels, descriptions, errors, and invalid state automatically for `Input`, `Textarea`, `Select`, `Checkbox`, `Switch`, `RadioGroup`, `Slider`, and `InputOTP`. Use `orientation="horizontal"` for checkbox/switch/radio rows, and `FieldSet` + `FieldLegend` for groups.
- **Replacing built-in parts:** Wrappers expose slot props that accept a replacement element or `null` so parts never double-render:
  - `DialogContent`, `AlertDialogContent`, `SheetContent`: `overlay`, `closeLabel` (Dialog/Sheet)
  - `Progress`: `track`
  - `TabsList`: `indicator`
  - `ScrollArea`: `scrollbar`, `viewportRef`, `onScroll`
  - `NavigationMenu`: `viewport` (`false` or `null` for one popup per item)
  - `AccordionTrigger`: `header` (defaults to `h3`)
- **Generic value roots:** `Tabs<T>`, `Accordion<T>`, `RadioGroup<T>`, `ToggleGroup<T>`, `CheckboxGroup<T>`, and `Select<T>` are generic in their value type.

## Available components (38)

Catalog JSON: https://ui.bridger.to/r/registry.json

- `accordion` — A stack of collapsible panels built on UI SDK. ([json](https://ui.bridger.to/r/accordion.json), [lab](https://ui.bridger.to/lab/accordion))
- `alert` — A callout for user attention. ([json](https://ui.bridger.to/r/alert.json), [lab](https://ui.bridger.to/lab/alert))
- `alert-dialog` — A modal dialog that interrupts to confirm an action. ([json](https://ui.bridger.to/r/alert-dialog.json), [lab](https://ui.bridger.to/lab/alert-dialog))
- `aspect-ratio` — Constrains content to a fixed width-to-height ratio. ([json](https://ui.bridger.to/r/aspect-ratio.json), [lab](https://ui.bridger.to/lab/aspect-ratio))
- `avatar` — An image with a text fallback, built on UI SDK. ([json](https://ui.bridger.to/r/avatar.json), [lab](https://ui.bridger.to/lab/avatar))
- `badge` — A small status or category label. ([json](https://ui.bridger.to/r/badge.json), [lab](https://ui.bridger.to/lab/badge))
- `breadcrumb` — A navigation trail showing the current location. ([json](https://ui.bridger.to/r/breadcrumb.json), [lab](https://ui.bridger.to/lab/breadcrumb))
- `button` — A button primitive built on UI SDK. ([json](https://ui.bridger.to/r/button.json), [lab](https://ui.bridger.to/lab/button))
- `card` — A content container with header, body, and footer slots. ([json](https://ui.bridger.to/r/card.json), [lab](https://ui.bridger.to/lab/card))
- `checkbox` — A checkbox primitive built on UI SDK. ([json](https://ui.bridger.to/r/checkbox.json), [lab](https://ui.bridger.to/lab/checkbox))
- `collapsible` — A single panel that expands and collapses, built on UI SDK. ([json](https://ui.bridger.to/r/collapsible.json), [lab](https://ui.bridger.to/lab/collapsible))
- `context-menu` — A menu triggered by right click, built on UI SDK. ([json](https://ui.bridger.to/r/context-menu.json), [lab](https://ui.bridger.to/lab/context-menu))
- `dialog` — A modal overlay for focused tasks, built on UI SDK. ([json](https://ui.bridger.to/r/dialog.json), [lab](https://ui.bridger.to/lab/dialog))
- `dropdown-menu` — A menu of actions triggered by a button, built on UI SDK. ([json](https://ui.bridger.to/r/dropdown-menu.json), [lab](https://ui.bridger.to/lab/dropdown-menu))
- `field` — Connects a control to its label, description and error, built on UI SDK. ([json](https://ui.bridger.to/r/field.json), [lab](https://ui.bridger.to/lab/field))
- `hover-card` — A preview card shown on hover, built on UI SDK. ([json](https://ui.bridger.to/r/hover-card.json), [lab](https://ui.bridger.to/lab/hover-card))
- `input` — A text input primitive built on UI SDK. ([json](https://ui.bridger.to/r/input.json), [lab](https://ui.bridger.to/lab/input))
- `input-otp` — A one-time password field, built on UI SDK. ([json](https://ui.bridger.to/r/input-otp.json), [lab](https://ui.bridger.to/lab/input-otp))
- `label` — A form label. ([json](https://ui.bridger.to/r/label.json), [lab](https://ui.bridger.to/lab/label))
- `menubar` — A horizontal set of menus, built on UI SDK. ([json](https://ui.bridger.to/r/menubar.json), [lab](https://ui.bridger.to/lab/menubar))
- `navigation-menu` — A site navigation menu with panels, built on UI SDK. ([json](https://ui.bridger.to/r/navigation-menu.json), [lab](https://ui.bridger.to/lab/navigation-menu))
- `pagination` — Controls for navigating between pages of content. ([json](https://ui.bridger.to/r/pagination.json), [lab](https://ui.bridger.to/lab/pagination))
- `popover` — A floating panel anchored to a trigger, built on UI SDK. ([json](https://ui.bridger.to/r/popover.json), [lab](https://ui.bridger.to/lab/popover))
- `progress` — A bar that shows task completion, built on UI SDK. ([json](https://ui.bridger.to/r/progress.json), [lab](https://ui.bridger.to/lab/progress))
- `radio-group` — A set of mutually exclusive options, built on UI SDK. ([json](https://ui.bridger.to/r/radio-group.json), [lab](https://ui.bridger.to/lab/radio-group))
- `scroll-area` — A scrollable region with custom scrollbars, built on UI SDK. ([json](https://ui.bridger.to/r/scroll-area.json), [lab](https://ui.bridger.to/lab/scroll-area))
- `select` — A dropdown for choosing one option, built on UI SDK. ([json](https://ui.bridger.to/r/select.json), [lab](https://ui.bridger.to/lab/select))
- `separator` — A visual divider. ([json](https://ui.bridger.to/r/separator.json), [lab](https://ui.bridger.to/lab/separator))
- `sheet` — A dialog that slides in from an edge, built on UI SDK. ([json](https://ui.bridger.to/r/sheet.json), [lab](https://ui.bridger.to/lab/sheet))
- `skeleton` — A placeholder shown while content loads. ([json](https://ui.bridger.to/r/skeleton.json), [lab](https://ui.bridger.to/lab/skeleton))
- `slider` — A control for selecting a value from a range, built on UI SDK. ([json](https://ui.bridger.to/r/slider.json), [lab](https://ui.bridger.to/lab/slider))
- `switch` — A switch primitive built on UI SDK. ([json](https://ui.bridger.to/r/switch.json), [lab](https://ui.bridger.to/lab/switch))
- `table` — A set of styled table primitives. ([json](https://ui.bridger.to/r/table.json), [lab](https://ui.bridger.to/lab/table))
- `tabs` — Toggle between related panels, built on UI SDK. ([json](https://ui.bridger.to/r/tabs.json), [lab](https://ui.bridger.to/lab/tabs))
- `textarea` — A multiline text field. ([json](https://ui.bridger.to/r/textarea.json), [lab](https://ui.bridger.to/lab/textarea))
- `toggle` — A two-state button, built on UI SDK. ([json](https://ui.bridger.to/r/toggle.json), [lab](https://ui.bridger.to/lab/toggle))
- `toggle-group` — A group of toggles that share state, built on UI SDK. ([json](https://ui.bridger.to/r/toggle-group.json), [lab](https://ui.bridger.to/lab/toggle-group))
- `tooltip` — A small popup with supplementary info, built on UI SDK. ([json](https://ui.bridger.to/r/tooltip.json), [lab](https://ui.bridger.to/lab/tooltip))
