create-deesse-app 0.2.3 → 0.4.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/dist/src/copy.d.ts +1 -1
- package/dist/src/copy.d.ts.map +1 -1
- package/dist/src/copy.js +50 -71
- package/dist/src/copy.js.map +1 -1
- package/dist/src/index.js +3 -2
- package/dist/src/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -5
- package/templates/default/.agents/skills/shadcn/SKILL.md +242 -0
- package/templates/default/.agents/skills/shadcn/agents/openai.yml +5 -0
- package/templates/default/.agents/skills/shadcn/assets/shadcn-small.png +0 -0
- package/templates/default/.agents/skills/shadcn/assets/shadcn.png +0 -0
- package/templates/default/.agents/skills/shadcn/cli.md +257 -0
- package/templates/default/.agents/skills/shadcn/customization.md +202 -0
- package/templates/default/.agents/skills/shadcn/evals/evals.json +47 -0
- package/templates/default/.agents/skills/shadcn/mcp.md +94 -0
- package/templates/default/.agents/skills/shadcn/rules/base-vs-radix.md +306 -0
- package/templates/default/.agents/skills/shadcn/rules/composition.md +195 -0
- package/templates/default/.agents/skills/shadcn/rules/forms.md +192 -0
- package/templates/default/.agents/skills/shadcn/rules/icons.md +101 -0
- package/templates/default/.agents/skills/shadcn/rules/styling.md +162 -0
- package/templates/default/AGENTS.md +5 -0
- package/templates/default/CLAUDE.md +1 -0
- package/templates/default/README.md +28 -0
- package/templates/default/components.json +25 -0
- package/templates/default/eslint.config.mjs +18 -0
- package/templates/default/next.config.ts +7 -0
- package/templates/default/package.json +50 -0
- package/templates/default/postcss.config.mjs +7 -0
- package/templates/default/public/file.svg +1 -0
- package/templates/default/public/globe.svg +1 -0
- package/templates/default/public/nesalia.svg +50 -0
- package/templates/default/public/window.svg +1 -0
- package/templates/default/skills-lock.json +10 -0
- package/templates/default/src/app/(deesse)/admin/[[...slug]]/page.tsx +20 -0
- package/templates/default/src/app/(deesse)/admin/layout.tsx +7 -0
- package/templates/default/src/app/(frontend)/page.tsx +50 -0
- package/templates/default/src/app/globals.css +130 -0
- package/templates/default/src/app/icon.svg +109 -0
- package/templates/default/src/app/layout.tsx +33 -0
- package/templates/default/src/app/page.tsx +50 -0
- package/templates/default/src/components/providers/index.tsx +9 -0
- package/templates/default/src/components/providers/theme-provider.tsx +11 -0
- package/templates/default/src/components/ui/accordion.tsx +81 -0
- package/templates/default/src/components/ui/alert-dialog.tsx +199 -0
- package/templates/default/src/components/ui/alert.tsx +76 -0
- package/templates/default/src/components/ui/aspect-ratio.tsx +11 -0
- package/templates/default/src/components/ui/avatar.tsx +112 -0
- package/templates/default/src/components/ui/badge.tsx +49 -0
- package/templates/default/src/components/ui/breadcrumb.tsx +122 -0
- package/templates/default/src/components/ui/button-group.tsx +83 -0
- package/templates/default/src/components/ui/button.tsx +67 -0
- package/templates/default/src/components/ui/calendar.tsx +222 -0
- package/templates/default/src/components/ui/card.tsx +103 -0
- package/templates/default/src/components/ui/carousel.tsx +242 -0
- package/templates/default/src/components/ui/chart.tsx +373 -0
- package/templates/default/src/components/ui/checkbox.tsx +33 -0
- package/templates/default/src/components/ui/collapsible.tsx +33 -0
- package/templates/default/src/components/ui/combobox.tsx +299 -0
- package/templates/default/src/components/ui/command.tsx +195 -0
- package/templates/default/src/components/ui/context-menu.tsx +263 -0
- package/templates/default/src/components/ui/dialog.tsx +168 -0
- package/templates/default/src/components/ui/direction.tsx +22 -0
- package/templates/default/src/components/ui/drawer.tsx +134 -0
- package/templates/default/src/components/ui/dropdown-menu.tsx +269 -0
- package/templates/default/src/components/ui/empty.tsx +104 -0
- package/templates/default/src/components/ui/field.tsx +238 -0
- package/templates/default/src/components/ui/hover-card.tsx +44 -0
- package/templates/default/src/components/ui/input-group.tsx +156 -0
- package/templates/default/src/components/ui/input-otp.tsx +87 -0
- package/templates/default/src/components/ui/input.tsx +19 -0
- package/templates/default/src/components/ui/item.tsx +196 -0
- package/templates/default/src/components/ui/kbd.tsx +26 -0
- package/templates/default/src/components/ui/label.tsx +24 -0
- package/templates/default/src/components/ui/menubar.tsx +280 -0
- package/templates/default/src/components/ui/native-select.tsx +52 -0
- package/templates/default/src/components/ui/navigation-menu.tsx +164 -0
- package/templates/default/src/components/ui/pagination.tsx +129 -0
- package/templates/default/src/components/ui/popover.tsx +89 -0
- package/templates/default/src/components/ui/progress.tsx +31 -0
- package/templates/default/src/components/ui/radio-group.tsx +44 -0
- package/templates/default/src/components/ui/resizable.tsx +50 -0
- package/templates/default/src/components/ui/scroll-area.tsx +55 -0
- package/templates/default/src/components/ui/select.tsx +192 -0
- package/templates/default/src/components/ui/separator.tsx +28 -0
- package/templates/default/src/components/ui/sheet.tsx +147 -0
- package/templates/default/src/components/ui/sidebar.tsx +702 -0
- package/templates/default/src/components/ui/skeleton.tsx +13 -0
- package/templates/default/src/components/ui/slider.tsx +59 -0
- package/templates/default/src/components/ui/sonner.tsx +49 -0
- package/templates/default/src/components/ui/spinner.tsx +10 -0
- package/templates/default/src/components/ui/switch.tsx +33 -0
- package/templates/default/src/components/ui/table.tsx +116 -0
- package/templates/default/src/components/ui/tabs.tsx +90 -0
- package/templates/default/src/components/ui/textarea.tsx +18 -0
- package/templates/default/src/components/ui/toggle-group.tsx +89 -0
- package/templates/default/src/components/ui/toggle.tsx +46 -0
- package/templates/default/src/components/ui/tooltip.tsx +57 -0
- package/templates/default/src/deesse.config.ts +11 -0
- package/templates/default/src/hooks/use-mobile.ts +19 -0
- package/templates/default/src/lib/utils.ts +6 -0
- package/templates/default/tsconfig.json +35 -0
- package/templates/minimal/.gitkeep +0 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# Customization & Theming
|
|
2
|
+
|
|
3
|
+
Components reference semantic CSS variable tokens. Change the variables to change every component.
|
|
4
|
+
|
|
5
|
+
## Contents
|
|
6
|
+
|
|
7
|
+
- How it works (CSS variables → Tailwind utilities → components)
|
|
8
|
+
- Color variables and OKLCH format
|
|
9
|
+
- Dark mode setup
|
|
10
|
+
- Changing the theme (presets, CSS variables)
|
|
11
|
+
- Adding custom colors (Tailwind v3 and v4)
|
|
12
|
+
- Border radius
|
|
13
|
+
- Customizing components (variants, className, wrappers)
|
|
14
|
+
- Checking for updates
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## How It Works
|
|
19
|
+
|
|
20
|
+
1. CSS variables defined in `:root` (light) and `.dark` (dark mode).
|
|
21
|
+
2. Tailwind maps them to utilities: `bg-primary`, `text-muted-foreground`, etc.
|
|
22
|
+
3. Components use these utilities — changing a variable changes all components that reference it.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Color Variables
|
|
27
|
+
|
|
28
|
+
Every color follows the `name` / `name-foreground` convention. The base variable is for backgrounds, `-foreground` is for text/icons on that background.
|
|
29
|
+
|
|
30
|
+
| Variable | Purpose |
|
|
31
|
+
| -------------------------------------------- | -------------------------------- |
|
|
32
|
+
| `--background` / `--foreground` | Page background and default text |
|
|
33
|
+
| `--card` / `--card-foreground` | Card surfaces |
|
|
34
|
+
| `--primary` / `--primary-foreground` | Primary buttons and actions |
|
|
35
|
+
| `--secondary` / `--secondary-foreground` | Secondary actions |
|
|
36
|
+
| `--muted` / `--muted-foreground` | Muted/disabled states |
|
|
37
|
+
| `--accent` / `--accent-foreground` | Hover and accent states |
|
|
38
|
+
| `--destructive` / `--destructive-foreground` | Error and destructive actions |
|
|
39
|
+
| `--border` | Default border color |
|
|
40
|
+
| `--input` | Form input borders |
|
|
41
|
+
| `--ring` | Focus ring color |
|
|
42
|
+
| `--chart-1` through `--chart-5` | Chart/data visualization |
|
|
43
|
+
| `--sidebar-*` | Sidebar-specific colors |
|
|
44
|
+
| `--surface` / `--surface-foreground` | Secondary surface |
|
|
45
|
+
|
|
46
|
+
Colors use OKLCH: `--primary: oklch(0.205 0 0)` where values are lightness (0–1), chroma (0 = gray), and hue (0–360).
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Dark Mode
|
|
51
|
+
|
|
52
|
+
Class-based toggle via `.dark` on the root element. In Next.js, use `next-themes`:
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import { ThemeProvider } from "next-themes"
|
|
56
|
+
|
|
57
|
+
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
|
|
58
|
+
{children}
|
|
59
|
+
</ThemeProvider>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Changing the Theme
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Apply a preset code from ui.shadcn.com.
|
|
68
|
+
npx shadcn@latest init --preset a2r6bw --force
|
|
69
|
+
|
|
70
|
+
# Switch to a named preset.
|
|
71
|
+
npx shadcn@latest init --preset radix-nova --force
|
|
72
|
+
npx shadcn@latest init --reinstall # update existing components to match
|
|
73
|
+
|
|
74
|
+
# Use a custom theme URL.
|
|
75
|
+
npx shadcn@latest init --preset "https://ui.shadcn.com/init?base=radix&style=nova&theme=blue&..." --force
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Or edit CSS variables directly in `globals.css`.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Adding Custom Colors
|
|
83
|
+
|
|
84
|
+
Add variables to the file at `tailwindCssFile` from `npx shadcn@latest info` (typically `globals.css`). Never create a new CSS file for this.
|
|
85
|
+
|
|
86
|
+
```css
|
|
87
|
+
/* 1. Define in the global CSS file. */
|
|
88
|
+
:root {
|
|
89
|
+
--warning: oklch(0.84 0.16 84);
|
|
90
|
+
--warning-foreground: oklch(0.28 0.07 46);
|
|
91
|
+
}
|
|
92
|
+
.dark {
|
|
93
|
+
--warning: oklch(0.41 0.11 46);
|
|
94
|
+
--warning-foreground: oklch(0.99 0.02 95);
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
```css
|
|
99
|
+
/* 2a. Register with Tailwind v4 (@theme inline). */
|
|
100
|
+
@theme inline {
|
|
101
|
+
--color-warning: var(--warning);
|
|
102
|
+
--color-warning-foreground: var(--warning-foreground);
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
When `tailwindVersion` is `"v3"` (check via `npx shadcn@latest info`), register in `tailwind.config.js` instead:
|
|
107
|
+
|
|
108
|
+
```js
|
|
109
|
+
// 2b. Register with Tailwind v3 (tailwind.config.js).
|
|
110
|
+
module.exports = {
|
|
111
|
+
theme: {
|
|
112
|
+
extend: {
|
|
113
|
+
colors: {
|
|
114
|
+
warning: "oklch(var(--warning) / <alpha-value>)",
|
|
115
|
+
"warning-foreground":
|
|
116
|
+
"oklch(var(--warning-foreground) / <alpha-value>)",
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
// 3. Use in components.
|
|
125
|
+
<div className="bg-warning text-warning-foreground">Warning</div>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Border Radius
|
|
131
|
+
|
|
132
|
+
`--radius` controls border radius globally. Components derive values from it (`rounded-lg` = `var(--radius)`, `rounded-md` = `calc(var(--radius) - 2px)`).
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Customizing Components
|
|
137
|
+
|
|
138
|
+
See also: [rules/styling.md](./rules/styling.md) for Incorrect/Correct examples.
|
|
139
|
+
|
|
140
|
+
Prefer these approaches in order:
|
|
141
|
+
|
|
142
|
+
### 1. Built-in variants
|
|
143
|
+
|
|
144
|
+
```tsx
|
|
145
|
+
<Button variant="outline" size="sm">Click</Button>
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### 2. Tailwind classes via `className`
|
|
149
|
+
|
|
150
|
+
```tsx
|
|
151
|
+
<Card className="max-w-md mx-auto">...</Card>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 3. Add a new variant
|
|
155
|
+
|
|
156
|
+
Edit the component source to add a variant via `cva`:
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
// components/ui/button.tsx
|
|
160
|
+
warning: "bg-warning text-warning-foreground hover:bg-warning/90",
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### 4. Wrapper components
|
|
164
|
+
|
|
165
|
+
Compose shadcn/ui primitives into higher-level components:
|
|
166
|
+
|
|
167
|
+
```tsx
|
|
168
|
+
export function ConfirmDialog({ title, description, onConfirm, children }) {
|
|
169
|
+
return (
|
|
170
|
+
<AlertDialog>
|
|
171
|
+
<AlertDialogTrigger asChild>{children}</AlertDialogTrigger>
|
|
172
|
+
<AlertDialogContent>
|
|
173
|
+
<AlertDialogHeader>
|
|
174
|
+
<AlertDialogTitle>{title}</AlertDialogTitle>
|
|
175
|
+
<AlertDialogDescription>{description}</AlertDialogDescription>
|
|
176
|
+
</AlertDialogHeader>
|
|
177
|
+
<AlertDialogFooter>
|
|
178
|
+
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
|
179
|
+
<AlertDialogAction onClick={onConfirm}>Confirm</AlertDialogAction>
|
|
180
|
+
</AlertDialogFooter>
|
|
181
|
+
</AlertDialogContent>
|
|
182
|
+
</AlertDialog>
|
|
183
|
+
)
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Checking for Updates
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
npx shadcn@latest add button --diff
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
To preview exactly what would change before updating, use `--dry-run` and `--diff`:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
npx shadcn@latest add button --dry-run # see all affected files
|
|
199
|
+
npx shadcn@latest add button --diff button.tsx # see the diff for a specific file
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
See [Updating Components in SKILL.md](./SKILL.md#updating-components) for the full smart merge workflow.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"skill_name": "shadcn",
|
|
3
|
+
"evals": [
|
|
4
|
+
{
|
|
5
|
+
"id": 1,
|
|
6
|
+
"prompt": "I'm building a Next.js app with shadcn/ui (base-nova preset, lucide icons). Create a settings form component with fields for: full name, email address, and notification preferences (email, SMS, push notifications as toggle options). Add validation states for required fields.",
|
|
7
|
+
"expected_output": "A React component using FieldGroup, Field, ToggleGroup, data-invalid/aria-invalid validation, gap-* spacing, and semantic colors.",
|
|
8
|
+
"files": [],
|
|
9
|
+
"expectations": [
|
|
10
|
+
"Uses FieldGroup and Field components for form layout instead of raw div with space-y",
|
|
11
|
+
"Uses Switch for independent on/off notification toggles (not looping Button with manual active state)",
|
|
12
|
+
"Uses data-invalid on Field and aria-invalid on the input control for validation states",
|
|
13
|
+
"Uses gap-* (e.g. gap-4, gap-6) instead of space-y-* or space-x-* for spacing",
|
|
14
|
+
"Uses semantic color tokens (e.g. bg-background, text-muted-foreground, text-destructive) instead of raw colors like bg-red-500",
|
|
15
|
+
"No manual dark: color overrides"
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"id": 2,
|
|
20
|
+
"prompt": "Create a dialog component for editing a user profile. It should have the user's avatar at the top, input fields for name and bio, and Save/Cancel buttons with appropriate icons. Using shadcn/ui with radix-nova preset and tabler icons.",
|
|
21
|
+
"expected_output": "A React component with DialogTitle, Avatar+AvatarFallback, data-icon on icon buttons, no icon sizing classes, tabler icon imports.",
|
|
22
|
+
"files": [],
|
|
23
|
+
"expectations": [
|
|
24
|
+
"Includes DialogTitle for accessibility (visible or with sr-only class)",
|
|
25
|
+
"Avatar component includes AvatarFallback",
|
|
26
|
+
"Icons on buttons use the data-icon attribute (data-icon=\"inline-start\" or data-icon=\"inline-end\")",
|
|
27
|
+
"No sizing classes on icons inside components (no size-4, w-4, h-4, etc.)",
|
|
28
|
+
"Uses tabler icons (@tabler/icons-react) instead of lucide-react",
|
|
29
|
+
"Uses asChild for custom triggers (radix preset)"
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"id": 3,
|
|
34
|
+
"prompt": "Create a dashboard component that shows 4 stat cards in a grid. Each card has a title, large number, percentage change badge, and a loading skeleton state. Using shadcn/ui with base-nova preset and lucide icons.",
|
|
35
|
+
"expected_output": "A React component with full Card composition, Skeleton for loading, Badge for changes, semantic colors, gap-* spacing.",
|
|
36
|
+
"files": [],
|
|
37
|
+
"expectations": [
|
|
38
|
+
"Uses full Card composition with CardHeader, CardTitle, CardContent (not dumping everything into CardContent)",
|
|
39
|
+
"Uses Skeleton component for loading placeholders instead of custom animate-pulse divs",
|
|
40
|
+
"Uses Badge component for percentage change instead of custom styled spans",
|
|
41
|
+
"Uses semantic color tokens instead of raw color values like bg-green-500 or text-red-600",
|
|
42
|
+
"Uses gap-* instead of space-y-* or space-x-* for spacing",
|
|
43
|
+
"Uses size-* when width and height are equal instead of separate w-* h-*"
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# shadcn MCP Server
|
|
2
|
+
|
|
3
|
+
The CLI includes an MCP server that lets AI assistants search, browse, view, and install components from registries.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Setup
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
shadcn mcp # start the MCP server (stdio)
|
|
11
|
+
shadcn mcp init # write config for your editor
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Editor config files:
|
|
15
|
+
|
|
16
|
+
| Editor | Config file |
|
|
17
|
+
|--------|------------|
|
|
18
|
+
| Claude Code | `.mcp.json` |
|
|
19
|
+
| Cursor | `.cursor/mcp.json` |
|
|
20
|
+
| VS Code | `.vscode/mcp.json` |
|
|
21
|
+
| OpenCode | `opencode.json` |
|
|
22
|
+
| Codex | `~/.codex/config.toml` (manual) |
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Tools
|
|
27
|
+
|
|
28
|
+
> **Tip:** MCP tools handle registry operations (search, view, install). For project configuration (aliases, framework, Tailwind version), use `npx shadcn@latest info` — there is no MCP equivalent.
|
|
29
|
+
|
|
30
|
+
### `shadcn:get_project_registries`
|
|
31
|
+
|
|
32
|
+
Returns registry names from `components.json`. Errors if no `components.json` exists.
|
|
33
|
+
|
|
34
|
+
**Input:** none
|
|
35
|
+
|
|
36
|
+
### `shadcn:list_items_in_registries`
|
|
37
|
+
|
|
38
|
+
Lists all items from one or more registries.
|
|
39
|
+
|
|
40
|
+
**Input:** `registries` (string[]), `limit` (number, optional), `offset` (number, optional)
|
|
41
|
+
|
|
42
|
+
### `shadcn:search_items_in_registries`
|
|
43
|
+
|
|
44
|
+
Fuzzy search across registries.
|
|
45
|
+
|
|
46
|
+
**Input:** `registries` (string[]), `query` (string), `limit` (number, optional), `offset` (number, optional)
|
|
47
|
+
|
|
48
|
+
### `shadcn:view_items_in_registries`
|
|
49
|
+
|
|
50
|
+
View item details including full file contents.
|
|
51
|
+
|
|
52
|
+
**Input:** `items` (string[]) — e.g. `["@shadcn/button", "@shadcn/card"]`
|
|
53
|
+
|
|
54
|
+
### `shadcn:get_item_examples_from_registries`
|
|
55
|
+
|
|
56
|
+
Find usage examples and demos with source code.
|
|
57
|
+
|
|
58
|
+
**Input:** `registries` (string[]), `query` (string) — e.g. `"accordion-demo"`, `"button example"`
|
|
59
|
+
|
|
60
|
+
### `shadcn:get_add_command_for_items`
|
|
61
|
+
|
|
62
|
+
Returns the CLI install command.
|
|
63
|
+
|
|
64
|
+
**Input:** `items` (string[]) — e.g. `["@shadcn/button"]`
|
|
65
|
+
|
|
66
|
+
### `shadcn:get_audit_checklist`
|
|
67
|
+
|
|
68
|
+
Returns a checklist for verifying components (imports, deps, lint, TypeScript).
|
|
69
|
+
|
|
70
|
+
**Input:** none
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Configuring Registries
|
|
75
|
+
|
|
76
|
+
Registries are set in `components.json`. The `@shadcn` registry is always built-in.
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"registries": {
|
|
81
|
+
"@acme": "https://acme.com/r/{name}.json",
|
|
82
|
+
"@private": {
|
|
83
|
+
"url": "https://private.com/r/{name}.json",
|
|
84
|
+
"headers": { "Authorization": "Bearer ${MY_TOKEN}" }
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
- Names must start with `@`.
|
|
91
|
+
- URLs must contain `{name}`.
|
|
92
|
+
- `${VAR}` references are resolved from environment variables.
|
|
93
|
+
|
|
94
|
+
Community registry index: `https://ui.shadcn.com/r/registries.json`
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
# Base vs Radix
|
|
2
|
+
|
|
3
|
+
API differences between `base` and `radix`. Check the `base` field from `npx shadcn@latest info`.
|
|
4
|
+
|
|
5
|
+
## Contents
|
|
6
|
+
|
|
7
|
+
- Composition: asChild vs render
|
|
8
|
+
- Button / trigger as non-button element
|
|
9
|
+
- Select (items prop, placeholder, positioning, multiple, object values)
|
|
10
|
+
- ToggleGroup (type vs multiple)
|
|
11
|
+
- Slider (scalar vs array)
|
|
12
|
+
- Accordion (type and defaultValue)
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Composition: asChild (radix) vs render (base)
|
|
17
|
+
|
|
18
|
+
Radix uses `asChild` to replace the default element. Base uses `render`. Don't wrap triggers in extra elements.
|
|
19
|
+
|
|
20
|
+
**Incorrect:**
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
<DialogTrigger>
|
|
24
|
+
<div>
|
|
25
|
+
<Button>Open</Button>
|
|
26
|
+
</div>
|
|
27
|
+
</DialogTrigger>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Correct (radix):**
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
<DialogTrigger asChild>
|
|
34
|
+
<Button>Open</Button>
|
|
35
|
+
</DialogTrigger>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Correct (base):**
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
<DialogTrigger render={<Button />}>Open</DialogTrigger>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
This applies to all trigger and close components: `DialogTrigger`, `SheetTrigger`, `AlertDialogTrigger`, `DropdownMenuTrigger`, `PopoverTrigger`, `TooltipTrigger`, `CollapsibleTrigger`, `DialogClose`, `SheetClose`, `NavigationMenuLink`, `BreadcrumbLink`, `SidebarMenuButton`, `Badge`, `Item`.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Button / trigger as non-button element (base only)
|
|
49
|
+
|
|
50
|
+
When `render` changes an element to a non-button (`<a>`, `<span>`), add `nativeButton={false}`.
|
|
51
|
+
|
|
52
|
+
**Incorrect (base):** missing `nativeButton={false}`.
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
<Button render={<a href="/docs" />}>Read the docs</Button>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Correct (base):**
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
<Button render={<a href="/docs" />} nativeButton={false}>
|
|
62
|
+
Read the docs
|
|
63
|
+
</Button>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Correct (radix):**
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
<Button asChild>
|
|
70
|
+
<a href="/docs">Read the docs</a>
|
|
71
|
+
</Button>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Same for triggers whose `render` is not a `Button`:
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
// base.
|
|
78
|
+
<PopoverTrigger render={<InputGroupAddon />} nativeButton={false}>
|
|
79
|
+
Pick date
|
|
80
|
+
</PopoverTrigger>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Select
|
|
86
|
+
|
|
87
|
+
**items prop (base only).** Base requires an `items` prop on the root. Radix uses inline JSX only.
|
|
88
|
+
|
|
89
|
+
**Incorrect (base):**
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
<Select>
|
|
93
|
+
<SelectTrigger><SelectValue placeholder="Select a fruit" /></SelectTrigger>
|
|
94
|
+
</Select>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Correct (base):**
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
const items = [
|
|
101
|
+
{ label: "Select a fruit", value: null },
|
|
102
|
+
{ label: "Apple", value: "apple" },
|
|
103
|
+
{ label: "Banana", value: "banana" },
|
|
104
|
+
]
|
|
105
|
+
|
|
106
|
+
<Select items={items}>
|
|
107
|
+
<SelectTrigger>
|
|
108
|
+
<SelectValue />
|
|
109
|
+
</SelectTrigger>
|
|
110
|
+
<SelectContent>
|
|
111
|
+
<SelectGroup>
|
|
112
|
+
{items.map((item) => (
|
|
113
|
+
<SelectItem key={item.value} value={item.value}>{item.label}</SelectItem>
|
|
114
|
+
))}
|
|
115
|
+
</SelectGroup>
|
|
116
|
+
</SelectContent>
|
|
117
|
+
</Select>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Correct (radix):**
|
|
121
|
+
|
|
122
|
+
```tsx
|
|
123
|
+
<Select>
|
|
124
|
+
<SelectTrigger>
|
|
125
|
+
<SelectValue placeholder="Select a fruit" />
|
|
126
|
+
</SelectTrigger>
|
|
127
|
+
<SelectContent>
|
|
128
|
+
<SelectGroup>
|
|
129
|
+
<SelectItem value="apple">Apple</SelectItem>
|
|
130
|
+
<SelectItem value="banana">Banana</SelectItem>
|
|
131
|
+
</SelectGroup>
|
|
132
|
+
</SelectContent>
|
|
133
|
+
</Select>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**Placeholder.** Base uses a `{ value: null }` item in the items array. Radix uses `<SelectValue placeholder="...">`.
|
|
137
|
+
|
|
138
|
+
**Content positioning.** Base uses `alignItemWithTrigger`. Radix uses `position`.
|
|
139
|
+
|
|
140
|
+
```tsx
|
|
141
|
+
// base.
|
|
142
|
+
<SelectContent alignItemWithTrigger={false} side="bottom">
|
|
143
|
+
|
|
144
|
+
// radix.
|
|
145
|
+
<SelectContent position="popper">
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Select — multiple selection and object values (base only)
|
|
151
|
+
|
|
152
|
+
Base supports `multiple`, render-function children on `SelectValue`, and object values with `itemToStringValue`. Radix is single-select with string values only.
|
|
153
|
+
|
|
154
|
+
**Correct (base — multiple selection):**
|
|
155
|
+
|
|
156
|
+
```tsx
|
|
157
|
+
<Select items={items} multiple defaultValue={[]}>
|
|
158
|
+
<SelectTrigger>
|
|
159
|
+
<SelectValue>
|
|
160
|
+
{(value: string[]) => value.length === 0 ? "Select fruits" : `${value.length} selected`}
|
|
161
|
+
</SelectValue>
|
|
162
|
+
</SelectTrigger>
|
|
163
|
+
...
|
|
164
|
+
</Select>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
**Correct (base — object values):**
|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
<Select defaultValue={plans[0]} itemToStringValue={(plan) => plan.name}>
|
|
171
|
+
<SelectTrigger>
|
|
172
|
+
<SelectValue>{(value) => value.name}</SelectValue>
|
|
173
|
+
</SelectTrigger>
|
|
174
|
+
...
|
|
175
|
+
</Select>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## ToggleGroup
|
|
181
|
+
|
|
182
|
+
Base uses a `multiple` boolean prop. Radix uses `type="single"` or `type="multiple"`.
|
|
183
|
+
|
|
184
|
+
**Incorrect (base):**
|
|
185
|
+
|
|
186
|
+
```tsx
|
|
187
|
+
<ToggleGroup type="single" defaultValue="daily">
|
|
188
|
+
<ToggleGroupItem value="daily">Daily</ToggleGroupItem>
|
|
189
|
+
</ToggleGroup>
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**Correct (base):**
|
|
193
|
+
|
|
194
|
+
```tsx
|
|
195
|
+
// Single (no prop needed), defaultValue is always an array.
|
|
196
|
+
<ToggleGroup defaultValue={["daily"]} spacing={2}>
|
|
197
|
+
<ToggleGroupItem value="daily">Daily</ToggleGroupItem>
|
|
198
|
+
<ToggleGroupItem value="weekly">Weekly</ToggleGroupItem>
|
|
199
|
+
</ToggleGroup>
|
|
200
|
+
|
|
201
|
+
// Multi-selection.
|
|
202
|
+
<ToggleGroup multiple>
|
|
203
|
+
<ToggleGroupItem value="bold">Bold</ToggleGroupItem>
|
|
204
|
+
<ToggleGroupItem value="italic">Italic</ToggleGroupItem>
|
|
205
|
+
</ToggleGroup>
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
**Correct (radix):**
|
|
209
|
+
|
|
210
|
+
```tsx
|
|
211
|
+
// Single, defaultValue is a string.
|
|
212
|
+
<ToggleGroup type="single" defaultValue="daily" spacing={2}>
|
|
213
|
+
<ToggleGroupItem value="daily">Daily</ToggleGroupItem>
|
|
214
|
+
<ToggleGroupItem value="weekly">Weekly</ToggleGroupItem>
|
|
215
|
+
</ToggleGroup>
|
|
216
|
+
|
|
217
|
+
// Multi-selection.
|
|
218
|
+
<ToggleGroup type="multiple">
|
|
219
|
+
<ToggleGroupItem value="bold">Bold</ToggleGroupItem>
|
|
220
|
+
<ToggleGroupItem value="italic">Italic</ToggleGroupItem>
|
|
221
|
+
</ToggleGroup>
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**Controlled single value:**
|
|
225
|
+
|
|
226
|
+
```tsx
|
|
227
|
+
// base — wrap/unwrap arrays.
|
|
228
|
+
const [value, setValue] = React.useState("normal")
|
|
229
|
+
<ToggleGroup value={[value]} onValueChange={(v) => setValue(v[0])}>
|
|
230
|
+
|
|
231
|
+
// radix — plain string.
|
|
232
|
+
const [value, setValue] = React.useState("normal")
|
|
233
|
+
<ToggleGroup type="single" value={value} onValueChange={setValue}>
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Slider
|
|
239
|
+
|
|
240
|
+
Base accepts a plain number for a single thumb. Radix always requires an array.
|
|
241
|
+
|
|
242
|
+
**Incorrect (base):**
|
|
243
|
+
|
|
244
|
+
```tsx
|
|
245
|
+
<Slider defaultValue={[50]} max={100} step={1} />
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
**Correct (base):**
|
|
249
|
+
|
|
250
|
+
```tsx
|
|
251
|
+
<Slider defaultValue={50} max={100} step={1} />
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
**Correct (radix):**
|
|
255
|
+
|
|
256
|
+
```tsx
|
|
257
|
+
<Slider defaultValue={[50]} max={100} step={1} />
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
Both use arrays for range sliders. Controlled `onValueChange` in base may need a cast:
|
|
261
|
+
|
|
262
|
+
```tsx
|
|
263
|
+
// base.
|
|
264
|
+
const [value, setValue] = React.useState([0.3, 0.7])
|
|
265
|
+
<Slider value={value} onValueChange={(v) => setValue(v as number[])} />
|
|
266
|
+
|
|
267
|
+
// radix.
|
|
268
|
+
const [value, setValue] = React.useState([0.3, 0.7])
|
|
269
|
+
<Slider value={value} onValueChange={setValue} />
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## Accordion
|
|
275
|
+
|
|
276
|
+
Radix requires `type="single"` or `type="multiple"` and supports `collapsible`. `defaultValue` is a string. Base uses no `type` prop, uses `multiple` boolean, and `defaultValue` is always an array.
|
|
277
|
+
|
|
278
|
+
**Incorrect (base):**
|
|
279
|
+
|
|
280
|
+
```tsx
|
|
281
|
+
<Accordion type="single" collapsible defaultValue="item-1">
|
|
282
|
+
<AccordionItem value="item-1">...</AccordionItem>
|
|
283
|
+
</Accordion>
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
**Correct (base):**
|
|
287
|
+
|
|
288
|
+
```tsx
|
|
289
|
+
<Accordion defaultValue={["item-1"]}>
|
|
290
|
+
<AccordionItem value="item-1">...</AccordionItem>
|
|
291
|
+
</Accordion>
|
|
292
|
+
|
|
293
|
+
// Multi-select.
|
|
294
|
+
<Accordion multiple defaultValue={["item-1", "item-2"]}>
|
|
295
|
+
<AccordionItem value="item-1">...</AccordionItem>
|
|
296
|
+
<AccordionItem value="item-2">...</AccordionItem>
|
|
297
|
+
</Accordion>
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
**Correct (radix):**
|
|
301
|
+
|
|
302
|
+
```tsx
|
|
303
|
+
<Accordion type="single" collapsible defaultValue="item-1">
|
|
304
|
+
<AccordionItem value="item-1">...</AccordionItem>
|
|
305
|
+
</Accordion>
|
|
306
|
+
```
|