@gradeui/ui 0.9.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/ui/accordion.md +30 -0
- package/components/ui/ai-chat-composer.md +37 -0
- package/components/ui/ai-chat.md +81 -0
- package/components/ui/alert.md +0 -0
- package/components/ui/app-shell.md +178 -0
- package/components/ui/avatar.md +29 -0
- package/components/ui/badge.md +18 -0
- package/components/ui/breadcrumb.md +101 -0
- package/components/ui/button.md +63 -0
- package/components/ui/calendar.md +39 -0
- package/components/ui/callout.md +45 -0
- package/components/ui/card.md +40 -0
- package/components/ui/carousel.md +56 -0
- package/components/ui/chart.md +48 -0
- package/components/ui/checkbox.md +20 -0
- package/components/ui/collapsible.md +28 -0
- package/components/ui/command.md +38 -0
- package/components/ui/date-picker.md +52 -0
- package/components/ui/dialog.md +40 -0
- package/components/ui/dropdown-menu.md +45 -0
- package/components/ui/flex.md +41 -0
- package/components/ui/grid.md +44 -0
- package/components/ui/hover-card.md +35 -0
- package/components/ui/input.md +17 -0
- package/components/ui/label.md +15 -0
- package/components/ui/map.md +80 -0
- package/components/ui/media-surface.md +61 -0
- package/components/ui/multi-select.md +114 -0
- package/components/ui/popover.md +43 -0
- package/components/ui/progress.md +15 -0
- package/components/ui/radio-group.md +37 -0
- package/components/ui/resizable.md +30 -0
- package/components/ui/rive-player.md +38 -0
- package/components/ui/row.md +32 -0
- package/components/ui/scroll-area.md +27 -0
- package/components/ui/select.md +24 -0
- package/components/ui/separator.md +16 -0
- package/components/ui/shader-preset-picker.md +26 -0
- package/components/ui/shader-preset-preview.md +24 -0
- package/components/ui/sheet.md +52 -0
- package/components/ui/side-menu.md +0 -0
- package/components/ui/sidebar.md +121 -0
- package/components/ui/simple-tabs.md +0 -0
- package/components/ui/skeleton.md +17 -0
- package/components/ui/slider.md +48 -0
- package/components/ui/sortable.md +101 -0
- package/components/ui/stack.md +50 -0
- package/components/ui/switch.md +20 -0
- package/components/ui/table.md +28 -0
- package/components/ui/tabs.md +56 -0
- package/components/ui/textarea.md +14 -0
- package/components/ui/three-scene.md +226 -0
- package/components/ui/toast.md +38 -0
- package/components/ui/toggle-group.md +43 -0
- package/components/ui/toggle.md +36 -0
- package/components/ui/toolbar.md +167 -0
- package/components/ui/tooltip.md +28 -0
- package/components/ui/video-player.md +27 -0
- package/dist/contracts.d.mts +14 -0
- package/dist/contracts.d.ts +14 -0
- package/dist/contracts.js +63 -0
- package/dist/contracts.js.map +1 -0
- package/dist/contracts.mjs +63 -0
- package/dist/contracts.mjs.map +1 -0
- package/dist/index.d.mts +1339 -191
- package/dist/index.d.ts +1339 -191
- package/dist/index.js +111 -49
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +111 -49
- package/dist/index.mjs.map +1 -1
- package/dist/map/google.js +1 -0
- package/dist/map/google.js.map +1 -1
- package/dist/map/google.mjs +1 -0
- package/dist/map/google.mjs.map +1 -1
- package/dist/map/mapbox.js +1 -0
- package/dist/map/mapbox.js.map +1 -1
- package/dist/map/mapbox.mjs +1 -0
- package/dist/map/mapbox.mjs.map +1 -1
- package/dist/map/maplibre.js +1 -0
- package/dist/map/maplibre.js.map +1 -1
- package/dist/map/maplibre.mjs +1 -0
- package/dist/map/maplibre.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/tailwind-preset.js +1 -1
- package/dist/tailwind-preset.js.map +1 -1
- package/dist/tailwind-preset.mjs +1 -1
- package/dist/tailwind-preset.mjs.map +1 -1
- package/package.json +26 -10
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Sidebar
|
|
3
|
+
import: "@gradeui/ui"
|
|
4
|
+
subcomponents: [SidebarHeader, SidebarContent, SidebarFooter, SidebarSection, SidebarItem]
|
|
5
|
+
props:
|
|
6
|
+
- Sidebar: collapsed?: boolean — controlled collapsed state (wire onCollapsedChange when set)
|
|
7
|
+
- Sidebar: defaultCollapsed?: boolean — uncontrolled initial value (default false)
|
|
8
|
+
- Sidebar: onCollapsedChange?: (next: boolean) => void
|
|
9
|
+
- Sidebar: collapsible?: boolean — show the affordance for the user to collapse (default true)
|
|
10
|
+
- Sidebar: variant?: 'rail' | 'panel' — outer chrome treatment. `rail` (default) is the classic nav rail with a single right-border + tracked width via `--gds-sidebar-width`; drops cleanly into `<AppShellNav placement="side">`. `panel` is a card-style floating sidebar with full border + rounded corners + parent-controlled width; use when the sidebar is one of several adjacent panes in a body row (e.g. Projects | Canvas | Settings). The compound children (Header/Content/Footer/Section/Item) are identical in both treatments.
|
|
11
|
+
- SidebarHeader: any children — brand / logo / org switcher; hides nothing when collapsed (centred)
|
|
12
|
+
- SidebarContent: any children — scrollable body
|
|
13
|
+
- SidebarFooter: any children — user block, settings link, pinned chrome
|
|
14
|
+
- SidebarSection: title?: ReactNode — group label; **uppercase tracking-wide muted** styling auto-applied (Notion / Linear / Slack-style "GAMES", "FAVORITES", "WORKSPACE" headers); hidden when sidebar is collapsed
|
|
15
|
+
- SidebarSection: icon?: ReactNode — optional icon beside the title
|
|
16
|
+
- SidebarSection: trailing?: ReactNode — **action(s) on the right edge of the header** — the canonical "+" / "..." slot (Notion's "+ Add page" next to Pages, Linear's "+" next to Favorites, Slack's "+" next to Channels). Pointer events isolated so a Button here doesn't toggle collapse.
|
|
17
|
+
- SidebarSection: collapsible?: boolean — title acts as expand/collapse trigger with a **chevron indicator** (default true). Set `false` for a static, non-clickable header.
|
|
18
|
+
- SidebarSection: defaultExpanded?: boolean — initial open state (default true)
|
|
19
|
+
- SidebarItem: icon?: ReactNode — leading icon
|
|
20
|
+
- SidebarItem: badge?: ReactNode — trailing count / label (hidden when collapsed)
|
|
21
|
+
- SidebarItem: active?: boolean — current route; adds aria-current="page"
|
|
22
|
+
- SidebarItem: href?: string — renders as <a>; for routing use `asChild` with your link component
|
|
23
|
+
- SidebarItem: asChild?: boolean — wrap a custom link (<Link href> from Next.js etc.) via Radix Slot
|
|
24
|
+
- SidebarItem: asButton?: boolean — render as <button> for action rows (open dialog, log out)
|
|
25
|
+
- SidebarItem: disabled?: boolean
|
|
26
|
+
- SidebarItem: collapsedLabel?: ReactNode — tooltip override when sidebar is collapsed (defaults to children text)
|
|
27
|
+
- SidebarItem: size?: 'sm' | 'md' — row size. `md` (default) is the standard `text-sm font-medium` nav row; `sm` is `text-xs` + lighter weight + tighter padding for visually subordinate rows (nested screens under a project, sub-pages under a section). Active state still wins on color + weight so the current row pops at either size.
|
|
28
|
+
- SidebarItem: description?: ReactNode — secondary line beneath the label (metadata like 'Edited 2m ago', '12 items', a brief description). Row layout adapts: label + description stacked vertically; icon vertically-centered against the stack; badge stays on trailing edge. Hidden when sidebar collapsed.
|
|
29
|
+
- SidebarTreeItem: description?: ReactNode — secondary line beneath the label, same shape as SidebarItem.description. Useful when a branch needs more than just a name (last-edited timestamp, item count, owner).
|
|
30
|
+
- SidebarTreeItem: trailing?: ReactNode — right-edge action slot (settings cog, more-actions overflow, "+ add child"). Rendered as a SIBLING of the branch button (not nested inside it, so `<button>` children in `trailing` stay valid HTML). Vertically centered against the row; click events are stopPropagation'd so a tap on a trailing button doesn't toggle expand/collapse. The branch row wrapper carries a `group/row` named-group, so consumer-provided trailing can opt into hover-only visibility via `hidden group-hover/row:flex` — the hover state is scoped to the branch row alone, not the nested children.
|
|
31
|
+
when_to_use: Vertical app navigation. Drop inside `<AppShellNav placement="side">` for full-page layouts. Compound API — `<SidebarHeader>` for brand, `<SidebarContent>` for the scrollable body of `<SidebarSection>` + `<SidebarItem>` rows, `<SidebarFooter>` for user / settings chrome. For top nav reach for TopMenu; for command-palette style search reach for Command.
|
|
32
|
+
composes_with: [AppShell (inside AppShellNav), Avatar (in Footer), Tooltip (auto-wrapped on collapsed items), Button (asChild for custom routing)]
|
|
33
|
+
aliases: [sidebar, side menu, sidemenu, navigation sidebar, app sidebar, side nav, side nav rail, master pane, sidebarmenu, navigation rail, react native drawer]
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
```jsx
|
|
37
|
+
<Sidebar defaultCollapsed={false}>
|
|
38
|
+
<SidebarHeader>
|
|
39
|
+
<div className="flex items-center gap-2 font-semibold">
|
|
40
|
+
<Logo className="h-5 w-5" />
|
|
41
|
+
<span>Acme</span>
|
|
42
|
+
</div>
|
|
43
|
+
</SidebarHeader>
|
|
44
|
+
|
|
45
|
+
<SidebarContent>
|
|
46
|
+
<SidebarSection title="Workspace">
|
|
47
|
+
<SidebarItem href="/" icon={<Home />} active>Dashboard</SidebarItem>
|
|
48
|
+
<SidebarItem href="/inbox" icon={<Inbox />} badge={3}>Inbox</SidebarItem>
|
|
49
|
+
<SidebarItem href="/team" icon={<Users />}>Team</SidebarItem>
|
|
50
|
+
</SidebarSection>
|
|
51
|
+
<SidebarSection title="Personal">
|
|
52
|
+
<SidebarItem href="/settings" icon={<Settings />}>Settings</SidebarItem>
|
|
53
|
+
</SidebarSection>
|
|
54
|
+
</SidebarContent>
|
|
55
|
+
|
|
56
|
+
<SidebarFooter>
|
|
57
|
+
<Row gap="sm" align="center">
|
|
58
|
+
<Avatar><AvatarFallback>AL</AvatarFallback></Avatar>
|
|
59
|
+
<Stack gap="none" className="text-xs">
|
|
60
|
+
<span className="font-medium">Ali</span>
|
|
61
|
+
<span className="text-muted-foreground">Pro plan</span>
|
|
62
|
+
</Stack>
|
|
63
|
+
</Row>
|
|
64
|
+
</SidebarFooter>
|
|
65
|
+
</Sidebar>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
```jsx
|
|
69
|
+
// With Next.js routing — wrap any link component via `asChild`.
|
|
70
|
+
import Link from "next/link";
|
|
71
|
+
|
|
72
|
+
<SidebarItem asChild icon={<Home />} active={pathname === "/"}>
|
|
73
|
+
<Link href="/">Dashboard</Link>
|
|
74
|
+
</SidebarItem>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
```jsx
|
|
78
|
+
// Action row — `asButton` renders a <button> instead of an <a>.
|
|
79
|
+
<SidebarItem asButton icon={<LogOut />} onClick={signOut}>
|
|
80
|
+
Sign out
|
|
81
|
+
</SidebarItem>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
```jsx
|
|
85
|
+
// Section header with a trailing action — the Notion / Linear / Slack
|
|
86
|
+
// "+" next to a section name. The trailing slot isolates pointer events
|
|
87
|
+
// from the collapse toggle, so the Button doesn't also flip expand.
|
|
88
|
+
<SidebarSection
|
|
89
|
+
title="Pages"
|
|
90
|
+
trailing={
|
|
91
|
+
<Button variant="ghost" size="icon" className="h-5 w-5">
|
|
92
|
+
<Plus className="h-3 w-3" />
|
|
93
|
+
</Button>
|
|
94
|
+
}
|
|
95
|
+
>
|
|
96
|
+
<SidebarItem>Notes</SidebarItem>
|
|
97
|
+
<SidebarItem>Drafts</SidebarItem>
|
|
98
|
+
</SidebarSection>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
```jsx
|
|
102
|
+
// Non-collapsible static header — for sections the user shouldn't
|
|
103
|
+
// be able to fold. `collapsible={false}` hides the chevron.
|
|
104
|
+
<SidebarSection title="Workspace" collapsible={false}>
|
|
105
|
+
<SidebarItem>...</SidebarItem>
|
|
106
|
+
</SidebarSection>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Anti-patterns
|
|
110
|
+
|
|
111
|
+
DO NOT pass a `sections={[...]}` data array — that was the old SideMenu shape (retired May 2026). Compose `<SidebarSection>` and `<SidebarItem>` directly so any non-list-shaped chrome (search input, drag handle, custom brand block) can sit alongside the nav.
|
|
112
|
+
|
|
113
|
+
DO NOT set `href` AND `onClick` AND `asChild` at once — pick one mode per row. `href` = anchor, `asButton` = button, `asChild` = wrap your own link component. Mixing modes makes the DOM ambiguous.
|
|
114
|
+
|
|
115
|
+
DO NOT use Sidebar for primary marketing-style top navigation — that's TopMenu. Sidebar is for app chrome (logged-in product surfaces), not landing pages.
|
|
116
|
+
|
|
117
|
+
DO NOT rely on the collapsed-state tooltip to convey critical-only information. When the sidebar is collapsed, only the icon is visible by default; the label is in the tooltip on hover, but mobile users + screen readers won't reliably see it. Keep icons recognisable and ship the label as actual text on hover/focus, not just as a tooltip.
|
|
118
|
+
|
|
119
|
+
DO NOT hand-roll an uppercase "SECTION NAME" header above your items. `<SidebarSection title="…">` already gives you the uppercase + tracking-wide + muted styling, plus the chevron + expand/collapse behaviour. If your design has a "+" or "..." next to the section name, use the `trailing` prop — don't render the action as a separate SidebarItem below the section.
|
|
120
|
+
|
|
121
|
+
DO NOT bypass `<Sidebar>` and compose an icon rail or projects pane from raw `<Stack>` + buttons. You lose the collapsed-state handling, the per-item tooltip, the `data-gds-part` markers that Studio's selection layer reads, and the consistent padding/gap CSS vars (`--gds-sidebar-*`). If you find yourself writing `<button className="flex items-center gap-3 rounded-md px-3 py-2 hover:bg-muted">{icon}{label}</button>`, that's a SidebarItem.
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Skeleton
|
|
3
|
+
import: "@gradeui/ui"
|
|
4
|
+
props:
|
|
5
|
+
- className?: string — required in practice; supply width/height utilities
|
|
6
|
+
- All native div HTML attrs
|
|
7
|
+
when_to_use: Loading placeholder for content whose shape you know. Set width/height via className to mimic the real content (e.g. "h-4 w-32"). Not a spinner — use it where the real thing will drop in.
|
|
8
|
+
composes_with: [Card, Avatar (inside a Skeleton for avatar loading), any layout]
|
|
9
|
+
aliases: [placeholder, shimmer, loader, loading state, redacted, redacted placeholder, shimmer placeholder, content placeholder, lottie placeholder]
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
```jsx
|
|
13
|
+
<div className="space-y-2">
|
|
14
|
+
<Skeleton className="h-4 w-3/4" />
|
|
15
|
+
<Skeleton className="h-4 w-1/2" />
|
|
16
|
+
</div>
|
|
17
|
+
```
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Slider
|
|
3
|
+
import: "@gradeui/ui"
|
|
4
|
+
props:
|
|
5
|
+
- value?: number[] — controlled value; ALWAYS an array even for a single-thumb slider (`[50]`)
|
|
6
|
+
- defaultValue?: number[] — uncontrolled initial; `[20, 80]` for a two-thumb range
|
|
7
|
+
- onValueChange?: (value: number[]) => void
|
|
8
|
+
- min?: number (default 0)
|
|
9
|
+
- max?: number (default 100)
|
|
10
|
+
- step?: number (default 1)
|
|
11
|
+
- disabled?: boolean
|
|
12
|
+
- orientation? "horizontal" | "vertical" (default "horizontal")
|
|
13
|
+
- dir? "ltr" | "rtl"
|
|
14
|
+
- inverted?: boolean — flip the visual direction
|
|
15
|
+
- name?: string — form name when posting natively
|
|
16
|
+
when_to_use: A continuous-ish numeric pick — volume, opacity, font size, price-range filters. Use a single-thumb slider for one value, two-thumb for a range. For a small set of discrete options (1-5 stars, sm/md/lg) prefer ToggleGroup. For free-text numeric entry use an Input type="number".
|
|
17
|
+
composes_with: [Label (mandatory above), Row (label + current value display), Card (settings rows)]
|
|
18
|
+
aliases: [slider, range slider, range input, volume, opacity slider, scrub, drag value, slider control, value slider, react native slider]
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
```jsx
|
|
22
|
+
// Single-thumb slider with the current value shown alongside.
|
|
23
|
+
<Stack gap="xs">
|
|
24
|
+
<Row justify="between" align="center">
|
|
25
|
+
<Label htmlFor="opacity">Opacity</Label>
|
|
26
|
+
<span className="text-sm text-muted-foreground tabular-nums">{value[0]}%</span>
|
|
27
|
+
</Row>
|
|
28
|
+
<Slider
|
|
29
|
+
id="opacity"
|
|
30
|
+
min={0}
|
|
31
|
+
max={100}
|
|
32
|
+
step={1}
|
|
33
|
+
value={value}
|
|
34
|
+
onValueChange={setValue}
|
|
35
|
+
/>
|
|
36
|
+
</Stack>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```jsx
|
|
40
|
+
// Two-thumb price-range filter.
|
|
41
|
+
<Slider
|
|
42
|
+
min={0}
|
|
43
|
+
max={500}
|
|
44
|
+
step={5}
|
|
45
|
+
defaultValue={[50, 250]}
|
|
46
|
+
onValueChange={setRange}
|
|
47
|
+
/>
|
|
48
|
+
```
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Sortable
|
|
3
|
+
import: "@gradeui/ui"
|
|
4
|
+
subcomponents: [Sortable.Item, Sortable.Handle]
|
|
5
|
+
props:
|
|
6
|
+
- Sortable: values: (string | number)[] — ordered list of unique ids; the source of truth for the order
|
|
7
|
+
- Sortable: onReorder?: (next: (string | number)[]) => void — fires with the new order after a drag that changed it
|
|
8
|
+
- Sortable: strategy?: "vertical" | "horizontal" | "grid" (default "vertical") — match the layout your items render in
|
|
9
|
+
- Sortable: disabled?: boolean — disable drag on every item
|
|
10
|
+
- Sortable.Item: value: string | number — must match one entry in the parent `values` array (identity, not React key)
|
|
11
|
+
- Sortable.Item: asChild?: boolean — render as the child element via Radix Slot
|
|
12
|
+
- Sortable.Item: disabled?: boolean — disable drag for this item only
|
|
13
|
+
- Sortable.Handle: asChild?: boolean — wrap a Button / icon as the drag grip
|
|
14
|
+
when_to_use: Drag-to-reorder lists, kanban-column reordering, sortable shelves, tab strips the user can rearrange. Pairs with any layout primitive — Stack for vertical lists, Row for horizontal strips, Grid for 2D card walls. For cross-container drag (drag a card from one column to another) hand-roll DndContext at the page level — Sortable v1 covers single-list reorder; Sortable.Group for cross-container is a planned follow-up. Reach for raw `@dnd-kit/core` if you need custom collision detection, drag overlays with arbitrary chrome, or non-list use cases (kanban swimlanes, draggable canvas nodes).
|
|
15
|
+
composes_with: [Stack (vertical lists), Row (horizontal strips), Grid (2D card walls), Card (typical item content), Button (as Sortable.Handle asChild)]
|
|
16
|
+
aliases: [sortable, reorder, drag and drop, dnd, draggable list, sortable list, kanban, drag to reorder, drag-drop, dragdroplist, drag handle, react native draggable flatlist]
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
```jsx
|
|
20
|
+
const [items, setItems] = React.useState([
|
|
21
|
+
{ id: "a", title: "First" },
|
|
22
|
+
{ id: "b", title: "Second" },
|
|
23
|
+
{ id: "c", title: "Third" },
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
<Sortable values={items.map(i => i.id)} onReorder={(ids) => {
|
|
27
|
+
setItems(ids.map(id => items.find(i => i.id === id)!));
|
|
28
|
+
}}>
|
|
29
|
+
<Stack gap="sm">
|
|
30
|
+
{items.map((item) => (
|
|
31
|
+
<Sortable.Item key={item.id} value={item.id}>
|
|
32
|
+
<Card>
|
|
33
|
+
<CardContent className="p-3">{item.title}</CardContent>
|
|
34
|
+
</Card>
|
|
35
|
+
</Sortable.Item>
|
|
36
|
+
))}
|
|
37
|
+
</Stack>
|
|
38
|
+
</Sortable>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
```jsx
|
|
42
|
+
// With a drag handle — only the grip activates drag; the rest of the
|
|
43
|
+
// row stays clickable for child Buttons / links.
|
|
44
|
+
<Sortable values={ids} onReorder={setIds} strategy="vertical">
|
|
45
|
+
<Stack gap="sm">
|
|
46
|
+
{items.map((item) => (
|
|
47
|
+
<Sortable.Item key={item.id} value={item.id}>
|
|
48
|
+
<Card>
|
|
49
|
+
<Row gap="sm" align="center" className="p-3">
|
|
50
|
+
<Sortable.Handle asChild>
|
|
51
|
+
<Button variant="ghost" size="icon">
|
|
52
|
+
<GripVertical className="h-4 w-4" />
|
|
53
|
+
</Button>
|
|
54
|
+
</Sortable.Handle>
|
|
55
|
+
<span className="flex-1">{item.title}</span>
|
|
56
|
+
<Button size="sm">Edit</Button>
|
|
57
|
+
</Row>
|
|
58
|
+
</Card>
|
|
59
|
+
</Sortable.Item>
|
|
60
|
+
))}
|
|
61
|
+
</Stack>
|
|
62
|
+
</Sortable>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
```jsx
|
|
66
|
+
// Horizontal tab strip — strategy="horizontal" + Row instead of Stack.
|
|
67
|
+
<Sortable values={tabIds} onReorder={setTabIds} strategy="horizontal">
|
|
68
|
+
<Row gap="xs">
|
|
69
|
+
{tabs.map((tab) => (
|
|
70
|
+
<Sortable.Item key={tab.id} value={tab.id}>
|
|
71
|
+
<Badge>{tab.label}</Badge>
|
|
72
|
+
</Sortable.Item>
|
|
73
|
+
))}
|
|
74
|
+
</Row>
|
|
75
|
+
</Sortable>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
```jsx
|
|
79
|
+
// 2D card grid — strategy="grid".
|
|
80
|
+
<Sortable values={photoIds} onReorder={setPhotoIds} strategy="grid">
|
|
81
|
+
<Grid cols="3" gap="md">
|
|
82
|
+
{photos.map((p) => (
|
|
83
|
+
<Sortable.Item key={p.id} value={p.id}>
|
|
84
|
+
<MediaSurface aspect="square" alt={p.alt} />
|
|
85
|
+
</Sortable.Item>
|
|
86
|
+
))}
|
|
87
|
+
</Grid>
|
|
88
|
+
</Sortable>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Anti-patterns
|
|
92
|
+
|
|
93
|
+
DO NOT add a `sortable` prop to Stack / Row / Grid — those primitives stay pure. Wrap them in `<Sortable>` to mark a collection sortable. Mixing layout and reorder concerns into one component balloons each primitive's contract for a feature 95% of stacks don't use, and loses you cross-layout consistency (one Sortable wrapping a Grid works exactly like one wrapping a Stack).
|
|
94
|
+
|
|
95
|
+
DO NOT use `key` as the sortable identity. `<Sortable.Item value={item.id}>` is the source of truth — `key={item.id}` is also fine for React's reconciler but `value` is what dnd-kit reads. They usually match; if they don't, drag-end will operate on the wrong row.
|
|
96
|
+
|
|
97
|
+
DO NOT try to mutate children directly to reorder. Sortable's data model is `state → children`. Reorder fires `onReorder(newValues)`; you update state; React re-renders children in the new order. Trying to read children's keys + reorder them imperatively fights React.
|
|
98
|
+
|
|
99
|
+
DO NOT wrap clickable items (Card with onClick, Button-bearing rows) without thinking about drag-vs-click conflict. The PointerSensor has a 4px activation distance so single clicks pass through, but if the row's primary affordance is "click to open detail," consider a `<Sortable.Handle>` so the user clicks the body for detail and drags only the grip.
|
|
100
|
+
|
|
101
|
+
DO NOT use Sortable for cross-container drag in v1. A single `<Sortable>` is one DndContext; the kanban "drag from To Do to Done" case needs one DndContext above multiple SortableContexts. Until `<Sortable.Group>` lands, that pattern needs hand-rolled `@dnd-kit/core` at the page level. Single-list, single-grid, single-strip reorder all work.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Stack
|
|
3
|
+
import: "@gradeui/ui"
|
|
4
|
+
role: layout
|
|
5
|
+
props:
|
|
6
|
+
- gap?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" (default "md") — vertical gap between children
|
|
7
|
+
- align?: "start" | "center" | "end" | "stretch" (default "stretch") — cross-axis (horizontal) alignment of children
|
|
8
|
+
- justify?: "start" | "center" | "end" | "between" | "around" | "evenly" (default "start") — main-axis (vertical) distribution. Reach for this on absolute-positioned overlays (`justify="end"` pins children to the bottom) and split footers (`justify="between"`).
|
|
9
|
+
- asChild?: boolean (default false) — render as the child element via Slot, so `<Stack asChild><section>…</section></Stack>` stamps Stack's classes onto the `<section>` rather than nesting a wrapper div
|
|
10
|
+
- className?: string
|
|
11
|
+
- children: React.ReactNode
|
|
12
|
+
when_to_use: Default top-level layout inside the main slot when composing two or more stacked regions (hero + content + footer, auth card + subtext, etc.). Prefer Stack over hand-rolled `flex flex-col gap-*` so the vertical rhythm is editable through the settings panel.
|
|
13
|
+
composes_with: [Section, Row, Split, Hero, any content component]
|
|
14
|
+
aliases: [stack, vstack, vertical, column, vertical layout, v-stack, vertical stack, lazyvstack]
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
```jsx
|
|
18
|
+
<Stack gap="lg">
|
|
19
|
+
<Hero>…</Hero>
|
|
20
|
+
<Section>…</Section>
|
|
21
|
+
<Section>…</Section>
|
|
22
|
+
</Stack>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```jsx
|
|
26
|
+
// Narrow centred column for auth / marketing copy.
|
|
27
|
+
<Stack gap="md" align="center" className="max-w-md mx-auto">
|
|
28
|
+
<CardTitle>Sign in</CardTitle>
|
|
29
|
+
<Input placeholder="Email" />
|
|
30
|
+
<Input placeholder="Password" type="password" />
|
|
31
|
+
<Button className="w-full">Continue</Button>
|
|
32
|
+
</Stack>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```jsx
|
|
36
|
+
// Hero overlay pinned to the bottom — use `justify="end"`, NOT
|
|
37
|
+
// `className="flex flex-col justify-end"`. Stack is already a flex
|
|
38
|
+
// column, so `flex flex-col` in className is dead weight.
|
|
39
|
+
<Stack justify="end" gap="md" className="absolute inset-0 p-10 max-w-2xl">
|
|
40
|
+
<Badge>Featured</Badge>
|
|
41
|
+
<h1 className="text-5xl font-semibold">Severance</h1>
|
|
42
|
+
<Button>Play</Button>
|
|
43
|
+
</Stack>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Anti-patterns
|
|
47
|
+
|
|
48
|
+
DO NOT add `flex flex-col` to Stack's className — Stack already applies `flex flex-col` as its base. Same for Row + `flex flex-row`. These are the literal definitions of the primitives.
|
|
49
|
+
|
|
50
|
+
DO NOT reach for `className="justify-end"` (or `justify-between`, etc.) when the new `justify` prop covers it. Inline-Tailwind layout escapes are how scaffolds slowly drift away from the design system — keep them in props so the settings panel can mutate them.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Switch
|
|
3
|
+
import: "@gradeui/ui"
|
|
4
|
+
props:
|
|
5
|
+
- checked?: boolean
|
|
6
|
+
- onCheckedChange?: (checked: boolean) => void
|
|
7
|
+
- defaultChecked?: boolean
|
|
8
|
+
- disabled?: boolean
|
|
9
|
+
- id?: string
|
|
10
|
+
when_to_use: Instant on/off setting ("Enable notifications", "Dark mode"). Commits on toggle — no submit button needed. For selecting-from-a-list use Checkbox.
|
|
11
|
+
composes_with: [Label (via htmlFor), Card (settings rows)]
|
|
12
|
+
aliases: [toggle, switch, on/off switch, ios toggle, toggle switch, switch control, react native switch]
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
```jsx
|
|
16
|
+
<div className="flex items-center justify-between">
|
|
17
|
+
<Label htmlFor="notifications">Email notifications</Label>
|
|
18
|
+
<Switch id="notifications" />
|
|
19
|
+
</div>
|
|
20
|
+
```
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Table
|
|
3
|
+
import: "@gradeui/ui"
|
|
4
|
+
subcomponents: [TableHeader, TableBody, TableFooter, TableRow, TableHead, TableCell, TableCaption]
|
|
5
|
+
props:
|
|
6
|
+
- Each subcomponent accepts native table HTML attrs
|
|
7
|
+
- No variants — styling follows the active theme tokens
|
|
8
|
+
when_to_use: Structured tabular data — rows × columns with alignment requirements. NOT a layout grid — for that use div+Tailwind grid utilities. Keep to <100 rows; larger datasets need virtualisation (not in DS).
|
|
9
|
+
composes_with: [Card (wrap the table), Badge (inside TableCell for status), Checkbox (row selection), Button (row actions)]
|
|
10
|
+
aliases: [table, table view, data table, datatable, grid view, data grid, rows and columns]
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
```jsx
|
|
14
|
+
<Table>
|
|
15
|
+
<TableHeader>
|
|
16
|
+
<TableRow>
|
|
17
|
+
<TableHead>Name</TableHead>
|
|
18
|
+
<TableHead className="text-right">Amount</TableHead>
|
|
19
|
+
</TableRow>
|
|
20
|
+
</TableHeader>
|
|
21
|
+
<TableBody>
|
|
22
|
+
<TableRow>
|
|
23
|
+
<TableCell>Invoice #001</TableCell>
|
|
24
|
+
<TableCell className="text-right">$250</TableCell>
|
|
25
|
+
</TableRow>
|
|
26
|
+
</TableBody>
|
|
27
|
+
</Table>
|
|
28
|
+
```
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Tabs
|
|
3
|
+
import: "@gradeui/ui"
|
|
4
|
+
subcomponents: [TabsList, TabsTrigger, TabsContent]
|
|
5
|
+
sizes: [sm, md, lg]
|
|
6
|
+
variants: [pill, underlined]
|
|
7
|
+
props:
|
|
8
|
+
- Tabs: defaultValue?, value?, onValueChange?, orientation?
|
|
9
|
+
- TabsList: size? (sm | md | lg, default md) — t-shirt scale aligned with Button/ToggleGroup heights; cascades to every TabsTrigger via context so set it once on the list
|
|
10
|
+
- TabsList: variant? (pill | underlined, default pill) — `pill` is the shadcn chip-on-muted look; `underlined` is the minimal text + bottom-border treatment (formerly the separate SimpleTabs component, collapsed into Tabs in May 2026). Cascades to triggers.
|
|
11
|
+
- TabsTrigger: value: string — matches a TabsContent value; tooltip?: string — when set, wraps the trigger in the design-system Tooltip and auto-applies aria-label (useful for icon-only triggers); requires a TooltipProvider somewhere above the tabs
|
|
12
|
+
- TabsContent: value: string — matches a TabsTrigger value
|
|
13
|
+
when_to_use: A small set of peer views within one surface (2–5 tabs). For primary nav use Side Menu/routing. For filters use a filter control, not tabs. Pick `variant="pill"` for app chrome (settings panels, in-card tab strips). Pick `variant="underlined"` for marketing/docs pages and browser-tab-style treatments.
|
|
14
|
+
composes_with: [Card (tabs inside a card body), Dialog, TooltipProvider (required for tooltip prop)]
|
|
15
|
+
aliases: [tabs, tab strip, tab bar, tab view, tabbed interface, pageviewcontroller, react native tab view, underlined tabs, page tabs, segment switcher, simple tabs]
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
```jsx
|
|
19
|
+
<Tabs defaultValue="details">
|
|
20
|
+
<TabsList>
|
|
21
|
+
<TabsTrigger value="details">Details</TabsTrigger>
|
|
22
|
+
<TabsTrigger value="activity">Activity</TabsTrigger>
|
|
23
|
+
</TabsList>
|
|
24
|
+
<TabsContent value="details">…</TabsContent>
|
|
25
|
+
<TabsContent value="activity">…</TabsContent>
|
|
26
|
+
</Tabs>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```jsx
|
|
30
|
+
// Icon-only triggers — `tooltip` adds the design-system Tooltip + aria-label.
|
|
31
|
+
<TooltipProvider>
|
|
32
|
+
<Tabs defaultValue="preview">
|
|
33
|
+
<TabsList size="sm">
|
|
34
|
+
<TabsTrigger value="preview" tooltip="Preview"><Eye /></TabsTrigger>
|
|
35
|
+
<TabsTrigger value="code" tooltip="Code"><Code /></TabsTrigger>
|
|
36
|
+
</TabsList>
|
|
37
|
+
<TabsContent value="preview">…</TabsContent>
|
|
38
|
+
<TabsContent value="code">…</TabsContent>
|
|
39
|
+
</Tabs>
|
|
40
|
+
</TooltipProvider>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
```jsx
|
|
44
|
+
// Underlined variant — replaces the old SimpleTabs component. Use
|
|
45
|
+
// `variant="underlined"` on the TabsList and it cascades to triggers.
|
|
46
|
+
<Tabs defaultValue="profile">
|
|
47
|
+
<TabsList variant="underlined">
|
|
48
|
+
<TabsTrigger value="profile">Profile</TabsTrigger>
|
|
49
|
+
<TabsTrigger value="team">Team</TabsTrigger>
|
|
50
|
+
<TabsTrigger value="billing">Billing</TabsTrigger>
|
|
51
|
+
</TabsList>
|
|
52
|
+
<TabsContent value="profile">…</TabsContent>
|
|
53
|
+
<TabsContent value="team">…</TabsContent>
|
|
54
|
+
<TabsContent value="billing">…</TabsContent>
|
|
55
|
+
</Tabs>
|
|
56
|
+
```
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Textarea
|
|
3
|
+
import: "@gradeui/ui"
|
|
4
|
+
props:
|
|
5
|
+
- All native textarea HTML attrs (rows, value, onChange, placeholder, disabled)
|
|
6
|
+
when_to_use: Multi-line text entry (descriptions, messages, comments). Pair with a Label. Single-line input → use Input instead.
|
|
7
|
+
composes_with: [Label, Form, Card (in CardContent)]
|
|
8
|
+
aliases: [text area, multiline, comment box, message field, text editor, multi-line text, multiline input, multiline text field, comments box, multiline textinput]
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
```jsx
|
|
12
|
+
<Label htmlFor="bio">Bio</Label>
|
|
13
|
+
<Textarea id="bio" rows={4} placeholder="Tell us about yourself." />
|
|
14
|
+
```
|