@autono/create-open-pages 0.1.0 → 0.3.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/README.md +6 -3
- package/dist/cli.js +1 -1
- package/package.json +1 -1
- package/template/.agents/skills/apply-comments/SKILL.md +4 -4
- package/template/.agents/skills/create-page/SKILL.md +26 -8
- package/template/.agents/skills/create-theme/SKILL.md +137 -150
- package/template/.agents/skills/current-page/SKILL.md +1 -1
- package/template/.agents/skills/page-authoring/SKILL.md +97 -42
- package/template/.agents/skills/page-authoring/references/interactivity.md +70 -22
- package/template/.agents/skills/page-authoring/references/layout-and-responsive.md +38 -17
- package/template/.agents/skills/page-authoring/references/typography-and-color.md +50 -32
- package/template/.agents/skills/shadcn/SKILL.md +277 -0
- package/template/.agents/skills/shadcn/assets/shadcn-small.png +0 -0
- package/template/.agents/skills/shadcn/assets/shadcn.png +0 -0
- package/template/.agents/skills/shadcn/cli.md +290 -0
- package/template/.agents/skills/shadcn/customization.md +209 -0
- package/template/.agents/skills/shadcn/mcp.md +105 -0
- package/template/.agents/skills/shadcn/registry.md +277 -0
- package/template/.agents/skills/shadcn/rules/base-vs-radix.md +306 -0
- package/template/.agents/skills/shadcn/rules/chat.md +224 -0
- package/template/.agents/skills/shadcn/rules/composition.md +213 -0
- package/template/.agents/skills/shadcn/rules/forms.md +192 -0
- package/template/.agents/skills/shadcn/rules/icons.md +101 -0
- package/template/.agents/skills/shadcn/rules/styling.md +185 -0
- package/template/AGENTS.md +7 -4
- package/template/README.md +21 -4
- package/template/components.json +9 -0
- package/template/hooks/use-mobile.ts +19 -0
- package/template/lib/utils.ts +6 -0
- package/template/package.json +24 -2
- package/template/pages/getting-started/index.tsx +51 -45
- package/template/styles/globals.css +118 -0
- package/template/tsconfig.json +13 -2
- package/template/ui/accordion.tsx +64 -0
- package/template/ui/alert-dialog.tsx +196 -0
- package/template/ui/alert.tsx +66 -0
- package/template/ui/aspect-ratio.tsx +11 -0
- package/template/ui/attachment.tsx +204 -0
- package/template/ui/avatar.tsx +107 -0
- package/template/ui/badge.tsx +48 -0
- package/template/ui/breadcrumb.tsx +109 -0
- package/template/ui/bubble.tsx +125 -0
- package/template/ui/button-group.tsx +83 -0
- package/template/ui/button.tsx +64 -0
- package/template/ui/calendar.tsx +218 -0
- package/template/ui/card.tsx +92 -0
- package/template/ui/carousel.tsx +241 -0
- package/template/ui/chart.tsx +374 -0
- package/template/ui/checkbox.tsx +32 -0
- package/template/ui/collapsible.tsx +31 -0
- package/template/ui/combobox.tsx +308 -0
- package/template/ui/command.tsx +182 -0
- package/template/ui/context-menu.tsx +252 -0
- package/template/ui/dialog.tsx +156 -0
- package/template/ui/direction.tsx +22 -0
- package/template/ui/drawer.tsx +133 -0
- package/template/ui/dropdown-menu.tsx +257 -0
- package/template/ui/empty.tsx +104 -0
- package/template/ui/field.tsx +246 -0
- package/template/ui/form.tsx +167 -0
- package/template/ui/hover-card.tsx +42 -0
- package/template/ui/input-group.tsx +170 -0
- package/template/ui/input-otp.tsx +77 -0
- package/template/ui/input.tsx +21 -0
- package/template/ui/item.tsx +193 -0
- package/template/ui/kbd.tsx +28 -0
- package/template/ui/label.tsx +22 -0
- package/template/ui/marker.tsx +69 -0
- package/template/ui/menubar.tsx +276 -0
- package/template/ui/message-scroller.tsx +128 -0
- package/template/ui/message.tsx +92 -0
- package/template/ui/native-select.tsx +62 -0
- package/template/ui/navigation-menu.tsx +168 -0
- package/template/ui/pagination.tsx +127 -0
- package/template/ui/popover.tsx +87 -0
- package/template/ui/progress.tsx +31 -0
- package/template/ui/radio-group.tsx +43 -0
- package/template/ui/resizable.tsx +53 -0
- package/template/ui/scroll-area.tsx +56 -0
- package/template/ui/select.tsx +190 -0
- package/template/ui/separator.tsx +26 -0
- package/template/ui/sheet.tsx +143 -0
- package/template/ui/sidebar.tsx +726 -0
- package/template/ui/skeleton.tsx +13 -0
- package/template/ui/slider.tsx +61 -0
- package/template/ui/sonner.tsx +40 -0
- package/template/ui/spinner.tsx +16 -0
- package/template/ui/switch.tsx +33 -0
- package/template/ui/table.tsx +116 -0
- package/template/ui/tabs.tsx +89 -0
- package/template/ui/textarea.tsx +18 -0
- package/template/ui/toggle-group.tsx +81 -0
- package/template/ui/toggle.tsx +47 -0
- package/template/ui/tooltip.tsx +55 -0
|
@@ -0,0 +1,209 @@
|
|
|
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 apply --preset a2r6bw
|
|
69
|
+
|
|
70
|
+
# Positional shorthand also works.
|
|
71
|
+
npx shadcn@latest apply a2r6bw
|
|
72
|
+
|
|
73
|
+
# Switch to a named preset and overwrite existing components.
|
|
74
|
+
npx shadcn@latest apply --preset nova
|
|
75
|
+
|
|
76
|
+
# Preserve existing components instead.
|
|
77
|
+
npx shadcn@latest init --preset nova --force --no-reinstall
|
|
78
|
+
|
|
79
|
+
# Use a custom theme URL.
|
|
80
|
+
npx shadcn@latest apply --preset "https://ui.shadcn.com/init?base=radix&style=nova&theme=blue&..."
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Or edit CSS variables directly in `globals.css`.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Adding Custom Colors
|
|
88
|
+
|
|
89
|
+
Add variables to the file at `tailwindCssFile` from `npx shadcn@latest info` (typically `globals.css`). Never create a new CSS file for this.
|
|
90
|
+
|
|
91
|
+
```css
|
|
92
|
+
/* 1. Define in the global CSS file. */
|
|
93
|
+
:root {
|
|
94
|
+
--warning: oklch(0.84 0.16 84);
|
|
95
|
+
--warning-foreground: oklch(0.28 0.07 46);
|
|
96
|
+
}
|
|
97
|
+
.dark {
|
|
98
|
+
--warning: oklch(0.41 0.11 46);
|
|
99
|
+
--warning-foreground: oklch(0.99 0.02 95);
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
```css
|
|
104
|
+
/* 2a. Register with Tailwind v4 (@theme inline). */
|
|
105
|
+
@theme inline {
|
|
106
|
+
--color-warning: var(--warning);
|
|
107
|
+
--color-warning-foreground: var(--warning-foreground);
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
When `tailwindVersion` is `"v3"` (check via `npx shadcn@latest info`), register in `tailwind.config.js` instead:
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
// 2b. Register with Tailwind v3 (tailwind.config.js).
|
|
115
|
+
module.exports = {
|
|
116
|
+
theme: {
|
|
117
|
+
extend: {
|
|
118
|
+
colors: {
|
|
119
|
+
warning: "oklch(var(--warning) / <alpha-value>)",
|
|
120
|
+
"warning-foreground":
|
|
121
|
+
"oklch(var(--warning-foreground) / <alpha-value>)",
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
// 3. Use in components.
|
|
130
|
+
<div className="bg-warning text-warning-foreground">Warning</div>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Border Radius
|
|
136
|
+
|
|
137
|
+
`--radius` controls border radius globally. Components derive values from it (`rounded-lg` = `var(--radius)`, `rounded-md` = `calc(var(--radius) - 2px)`).
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Customizing Components
|
|
142
|
+
|
|
143
|
+
See also: [rules/styling.md](./rules/styling.md) for Incorrect/Correct examples.
|
|
144
|
+
|
|
145
|
+
Prefer these approaches in order:
|
|
146
|
+
|
|
147
|
+
### 1. Built-in variants
|
|
148
|
+
|
|
149
|
+
```tsx
|
|
150
|
+
<Button variant="outline" size="sm">
|
|
151
|
+
Click
|
|
152
|
+
</Button>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### 2. Tailwind classes via `className`
|
|
156
|
+
|
|
157
|
+
```tsx
|
|
158
|
+
<Card className="mx-auto max-w-md">...</Card>
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### 3. Add a new variant
|
|
162
|
+
|
|
163
|
+
Edit the component source to add a variant via `cva`:
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
// components/ui/button.tsx
|
|
167
|
+
warning: "bg-warning text-warning-foreground hover:bg-warning/90",
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### 4. Wrapper components
|
|
171
|
+
|
|
172
|
+
Compose shadcn/ui primitives into higher-level components:
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
export function ConfirmDialog({ title, description, onConfirm, children }) {
|
|
176
|
+
return (
|
|
177
|
+
<AlertDialog>
|
|
178
|
+
<AlertDialogTrigger asChild>{children}</AlertDialogTrigger>
|
|
179
|
+
<AlertDialogContent>
|
|
180
|
+
<AlertDialogHeader>
|
|
181
|
+
<AlertDialogTitle>{title}</AlertDialogTitle>
|
|
182
|
+
<AlertDialogDescription>{description}</AlertDialogDescription>
|
|
183
|
+
</AlertDialogHeader>
|
|
184
|
+
<AlertDialogFooter>
|
|
185
|
+
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
|
186
|
+
<AlertDialogAction onClick={onConfirm}>Confirm</AlertDialogAction>
|
|
187
|
+
</AlertDialogFooter>
|
|
188
|
+
</AlertDialogContent>
|
|
189
|
+
</AlertDialog>
|
|
190
|
+
)
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Checking for Updates
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
npx shadcn@latest add button --diff
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
To preview exactly what would change before updating, use `--dry-run` and `--diff`:
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
npx shadcn@latest add button --dry-run # see all affected files
|
|
206
|
+
npx shadcn@latest add button --diff button.tsx # see the diff for a specific file
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
See [Updating Components in SKILL.md](./SKILL.md#updating-components) for the full smart merge workflow.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# shadcn MCP Server
|
|
2
|
+
|
|
3
|
+
The CLI includes an MCP server that lets AI assistants search, browse, view, and install items 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. Registries can be configured
|
|
39
|
+
namespaces such as `@acme`, public GitHub sources such as `owner/repo`, or
|
|
40
|
+
registry catalog URLs. Omit `registries` to list from every registry configured
|
|
41
|
+
in `components.json`.
|
|
42
|
+
|
|
43
|
+
**Input:** `registries` (string[], optional — omit for all configured), `types` (string[], optional — e.g. `["ui", "block"]`), `limit` (number, optional, defaults to 100), `offset` (number, optional)
|
|
44
|
+
|
|
45
|
+
### `shadcn:search_items_in_registries`
|
|
46
|
+
|
|
47
|
+
Fuzzy search across registries. Registries can be configured namespaces, public
|
|
48
|
+
GitHub sources, or registry catalog URLs. Omit `registries` to search every
|
|
49
|
+
registry configured in `components.json` — e.g. "find me a hero" across all
|
|
50
|
+
configured registries.
|
|
51
|
+
|
|
52
|
+
**Input:** `registries` (string[], optional — omit for all configured), `query` (string), `types` (string[], optional — e.g. `["ui", "block"]`), `limit` (number, optional, defaults to 100), `offset` (number, optional)
|
|
53
|
+
|
|
54
|
+
### `shadcn:view_items_in_registries`
|
|
55
|
+
|
|
56
|
+
View item details including full file contents.
|
|
57
|
+
|
|
58
|
+
**Input:** `items` (string[]) — e.g.
|
|
59
|
+
`["@shadcn/button", "@shadcn/card", "owner/repo/item"]`
|
|
60
|
+
|
|
61
|
+
### `shadcn:get_item_examples_from_registries`
|
|
62
|
+
|
|
63
|
+
Find usage examples and demos with source code. Omit `registries` to search
|
|
64
|
+
every registry configured in `components.json`.
|
|
65
|
+
|
|
66
|
+
**Input:** `registries` (string[], optional — omit for all configured), `query` (string) — e.g. `"accordion-demo"`, `"button example"`
|
|
67
|
+
|
|
68
|
+
### `shadcn:get_add_command_for_items`
|
|
69
|
+
|
|
70
|
+
Returns the CLI install command.
|
|
71
|
+
|
|
72
|
+
**Input:** `items` (string[]) — e.g. `["@shadcn/button"]`
|
|
73
|
+
|
|
74
|
+
### `shadcn:get_audit_checklist`
|
|
75
|
+
|
|
76
|
+
Returns a checklist for verifying components (imports, deps, lint, TypeScript).
|
|
77
|
+
|
|
78
|
+
**Input:** none
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Configuring Registries
|
|
83
|
+
|
|
84
|
+
Namespaced and authenticated registries are set in `components.json`. The
|
|
85
|
+
`@shadcn` registry is always built-in. Public GitHub registries can also be used
|
|
86
|
+
directly as `owner/repo` registry sources when the repository has a root
|
|
87
|
+
`registry.json`; they do not need `components.json` configuration.
|
|
88
|
+
|
|
89
|
+
```json
|
|
90
|
+
{
|
|
91
|
+
"registries": {
|
|
92
|
+
"@acme": "https://acme.com/r/{name}.json",
|
|
93
|
+
"@private": {
|
|
94
|
+
"url": "https://private.com/r/{name}.json",
|
|
95
|
+
"headers": { "Authorization": "Bearer ${MY_TOKEN}" }
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
- Names must start with `@`.
|
|
102
|
+
- URLs must contain `{name}`.
|
|
103
|
+
- `${VAR}` references are resolved from environment variables.
|
|
104
|
+
|
|
105
|
+
Community registry index: `https://ui.shadcn.com/r/registries.json`
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
# Registry Authoring and Addresses
|
|
2
|
+
|
|
3
|
+
Use this reference when the user wants to create, fix, publish, or reason about
|
|
4
|
+
a shadcn registry.
|
|
5
|
+
|
|
6
|
+
## Mental Model
|
|
7
|
+
|
|
8
|
+
A registry has two forms:
|
|
9
|
+
|
|
10
|
+
- **Source registry**: an authored `registry.json` in a project or repository.
|
|
11
|
+
It may use `include` and file paths that point at source files.
|
|
12
|
+
- **Built registry**: generated JSON files served to CLI consumers, usually
|
|
13
|
+
from `public/r`. Use `npx shadcn@latest build` to create this form.
|
|
14
|
+
|
|
15
|
+
The CLI installer consumes registry item payloads. A source registry is a way to
|
|
16
|
+
author those payloads from real files.
|
|
17
|
+
|
|
18
|
+
Registry items are not limited to React components. They can distribute
|
|
19
|
+
components, hooks, utilities, design tokens, pages, config files, docs, rules,
|
|
20
|
+
workflows, templates, MCP files, and other project files.
|
|
21
|
+
|
|
22
|
+
## Root `registry.json`
|
|
23
|
+
|
|
24
|
+
The root registry file should define registry metadata and either `items` or
|
|
25
|
+
`include`.
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"$schema": "https://ui.shadcn.com/schema/registry.json",
|
|
30
|
+
"name": "acme",
|
|
31
|
+
"homepage": "https://acme.com",
|
|
32
|
+
"items": [
|
|
33
|
+
{
|
|
34
|
+
"name": "absolute-url",
|
|
35
|
+
"type": "registry:lib",
|
|
36
|
+
"title": "Absolute URL",
|
|
37
|
+
"description": "A utility to turn any path into an absolute URL.",
|
|
38
|
+
"files": [
|
|
39
|
+
{
|
|
40
|
+
"path": "lib/absolute-url.ts",
|
|
41
|
+
"type": "registry:lib"
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Root registry rules:
|
|
50
|
+
|
|
51
|
+
- Root `registry.json` must include `name` and `homepage`.
|
|
52
|
+
- `items` is an array of registry item definitions.
|
|
53
|
+
- `include` may be used to split the source registry into multiple files.
|
|
54
|
+
- Included registry files may omit `name` and `homepage`.
|
|
55
|
+
|
|
56
|
+
## Include
|
|
57
|
+
|
|
58
|
+
Use `include` to keep large registries modular.
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"$schema": "https://ui.shadcn.com/schema/registry.json",
|
|
63
|
+
"name": "acme",
|
|
64
|
+
"homepage": "https://acme.com",
|
|
65
|
+
"include": ["registry/ui/registry.json", "registry/blocks/registry.json"]
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Include rules:
|
|
70
|
+
|
|
71
|
+
- Include paths are relative to the `registry.json` that declares them.
|
|
72
|
+
- Include paths must explicitly point to a `registry.json` file.
|
|
73
|
+
- Do not use remote URLs, absolute paths, or parent traversal (`..`).
|
|
74
|
+
- Item file paths are relative to the registry file that declares the item.
|
|
75
|
+
- Duplicate item names fail across the resolved registry.
|
|
76
|
+
|
|
77
|
+
Example included file:
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"items": [
|
|
82
|
+
{
|
|
83
|
+
"name": "button",
|
|
84
|
+
"type": "registry:ui",
|
|
85
|
+
"files": [
|
|
86
|
+
{
|
|
87
|
+
"path": "button.tsx",
|
|
88
|
+
"type": "registry:ui"
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
If this file is at `registry/ui/registry.json`, then `button.tsx` is read from
|
|
97
|
+
`registry/ui/button.tsx`, and the built item path is emitted relative to the
|
|
98
|
+
root registry.
|
|
99
|
+
|
|
100
|
+
## Item Definitions
|
|
101
|
+
|
|
102
|
+
Common item fields:
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"name": "login-form",
|
|
107
|
+
"type": "registry:block",
|
|
108
|
+
"title": "Login Form",
|
|
109
|
+
"description": "A login form with email and password fields.",
|
|
110
|
+
"dependencies": ["zod"],
|
|
111
|
+
"registryDependencies": ["button", "input", "label"],
|
|
112
|
+
"files": [
|
|
113
|
+
{
|
|
114
|
+
"path": "blocks/login-form.tsx",
|
|
115
|
+
"type": "registry:block"
|
|
116
|
+
}
|
|
117
|
+
],
|
|
118
|
+
"cssVars": {
|
|
119
|
+
"light": {
|
|
120
|
+
"brand": "oklch(0.62 0.18 250)"
|
|
121
|
+
},
|
|
122
|
+
"dark": {
|
|
123
|
+
"brand": "oklch(0.72 0.16 250)"
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Important fields:
|
|
130
|
+
|
|
131
|
+
- `name`: the installable item name. It is not necessarily a file path.
|
|
132
|
+
- `type`: one of the registry item types, such as `registry:ui`,
|
|
133
|
+
`registry:block`, `registry:lib`, `registry:hook`, `registry:file`,
|
|
134
|
+
`registry:page`, `registry:theme`, `registry:style`, `registry:font`, or
|
|
135
|
+
`registry:item`.
|
|
136
|
+
- `files`: source files copied or generated by the item.
|
|
137
|
+
- `dependencies`: npm runtime dependencies.
|
|
138
|
+
- `devDependencies`: npm development dependencies.
|
|
139
|
+
- `registryDependencies`: other registry items required by this item.
|
|
140
|
+
- `cssVars`, `css`, `tailwind`, `envVars`, and `docs`: optional install-time
|
|
141
|
+
additions.
|
|
142
|
+
|
|
143
|
+
File rules:
|
|
144
|
+
|
|
145
|
+
- File paths are relative to the declaring `registry.json`.
|
|
146
|
+
- `registry:file` and `registry:page` files require a `target`.
|
|
147
|
+
- Do not use remote file URLs in source registry file paths.
|
|
148
|
+
- Keep source files copy-pasteable: no hidden app-only imports.
|
|
149
|
+
|
|
150
|
+
## Registry Dependencies
|
|
151
|
+
|
|
152
|
+
`registryDependencies` entries are item addresses, not file paths.
|
|
153
|
+
|
|
154
|
+
```json
|
|
155
|
+
{
|
|
156
|
+
"name": "login-form",
|
|
157
|
+
"type": "registry:block",
|
|
158
|
+
"registryDependencies": ["button", "@acme/input", "acme/ui/card#v1.2.0"],
|
|
159
|
+
"files": [
|
|
160
|
+
{
|
|
161
|
+
"path": "blocks/login-form.tsx",
|
|
162
|
+
"type": "registry:block"
|
|
163
|
+
}
|
|
164
|
+
]
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Dependency rules:
|
|
169
|
+
|
|
170
|
+
- Bare names such as `"button"` mean official shadcn items.
|
|
171
|
+
- Bare names never mean same-registry or same-repository items.
|
|
172
|
+
- Namespaced dependencies use `@namespace/item-name`.
|
|
173
|
+
- GitHub dependencies use `owner/repo/item-name`.
|
|
174
|
+
- Pin GitHub dependencies with `owner/repo/item-name#ref` when needed.
|
|
175
|
+
- Refs are not inherited. If `owner/repo/foo#v2` depends on `bar` from the same
|
|
176
|
+
repo at `v2`, write `owner/repo/bar#v2`.
|
|
177
|
+
- Do not use relative dependencies such as `"./bar"`.
|
|
178
|
+
|
|
179
|
+
## Address Schemes
|
|
180
|
+
|
|
181
|
+
When reasoning about a registry item string, classify it first.
|
|
182
|
+
|
|
183
|
+
| Address | Scheme | Meaning |
|
|
184
|
+
| ----------------------------------- | --------- | ------------------------------------------------------------ |
|
|
185
|
+
| `button` | shadcn | Official shadcn item named `button`. |
|
|
186
|
+
| `@acme/button` | namespace | Item `button` from configured registry `@acme`. |
|
|
187
|
+
| `@acme/ui/button` | namespace | Item `ui/button` from configured registry `@acme`. |
|
|
188
|
+
| `https://example.com/r/button.json` | url | Built registry item JSON at that URL. |
|
|
189
|
+
| `./button.json` | file | Built registry item JSON on disk. |
|
|
190
|
+
| `acme/ui/button` | github | Item `button` from GitHub repo `acme/ui`. |
|
|
191
|
+
| `acme/ui/forms/login#main` | github | Item `forms/login` from GitHub repo `acme/ui` at ref `main`. |
|
|
192
|
+
|
|
193
|
+
For namespace and GitHub addresses, slashful item names are allowed and are item
|
|
194
|
+
names, not file paths. Addresses ending in `.json` keep file-address
|
|
195
|
+
precedence, so `acme/ui/data/schema.json` is treated as a file path, not a
|
|
196
|
+
GitHub item address.
|
|
197
|
+
|
|
198
|
+
## GitHub Registries
|
|
199
|
+
|
|
200
|
+
A public GitHub repository can act as a source registry when it has a root
|
|
201
|
+
`registry.json`.
|
|
202
|
+
|
|
203
|
+
```txt
|
|
204
|
+
owner/repo/item-name[#ref]
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Rules:
|
|
208
|
+
|
|
209
|
+
- The first two path segments are GitHub owner and repo.
|
|
210
|
+
- All remaining path segments are the registry item name.
|
|
211
|
+
- The source entrypoint is always root `registry.json`.
|
|
212
|
+
- GitHub registries are source registries consumed directly by the CLI. They do
|
|
213
|
+
not require `shadcn build` or generated item JSON files.
|
|
214
|
+
- `include` follows the same source-registry rules as local registries.
|
|
215
|
+
- Currently, GitHub addresses support public `github.com` repositories only.
|
|
216
|
+
- Private repos and GitHub Enterprise require explicit product decisions.
|
|
217
|
+
|
|
218
|
+
When implementing GitHub registry fetching, resolve refs to a commit SHA before
|
|
219
|
+
reading source files. Do not read moving refs directly from
|
|
220
|
+
`raw.githubusercontent.com`, because branch-like refs can be cached for several
|
|
221
|
+
minutes.
|
|
222
|
+
|
|
223
|
+
Preferred flow:
|
|
224
|
+
|
|
225
|
+
```txt
|
|
226
|
+
owner/repo[#ref]
|
|
227
|
+
-> resolve ref with git ls-remote
|
|
228
|
+
-> commit SHA
|
|
229
|
+
-> read https://raw.githubusercontent.com/{owner}/{repo}/{sha}/registry.json
|
|
230
|
+
-> read includes and item files from the same SHA
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
This keeps a command on one consistent repository snapshot.
|
|
234
|
+
|
|
235
|
+
Full 40-character commit SHAs are already stable and can be used directly.
|
|
236
|
+
Branches, tags, and short refs require Git so the CLI can resolve them to a
|
|
237
|
+
commit SHA first.
|
|
238
|
+
|
|
239
|
+
## Build and Verify
|
|
240
|
+
|
|
241
|
+
Use the CLI to build source registries:
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
npx shadcn@latest build
|
|
245
|
+
npx shadcn@latest build registry.json --output public/r
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
Use CLI commands to inspect the result:
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
npx shadcn@latest list @acme
|
|
252
|
+
npx shadcn@latest search @acme -q "login"
|
|
253
|
+
npx shadcn@latest view @acme/login-form
|
|
254
|
+
npx shadcn@latest add @acme/login-form --dry-run
|
|
255
|
+
npx shadcn@latest registry validate ./registry.json
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Use GitHub addresses directly for public GitHub registries:
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
npx shadcn@latest list owner/repo
|
|
262
|
+
npx shadcn@latest search owner/repo -q "login"
|
|
263
|
+
npx shadcn@latest view owner/repo/item
|
|
264
|
+
npx shadcn@latest add owner/repo/item --dry-run
|
|
265
|
+
npx shadcn@latest registry validate owner/repo
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
When working on registry implementation in the shadcn/ui codebase:
|
|
269
|
+
|
|
270
|
+
- Keep address parsing pure and testable.
|
|
271
|
+
- Do not add side effects to validators.
|
|
272
|
+
- Preserve existing behavior for official shadcn, namespace, URL, and file
|
|
273
|
+
schemes.
|
|
274
|
+
- Add tests for address parsing, source loading, dependency resolution, list,
|
|
275
|
+
search, view, and add paths.
|
|
276
|
+
- Prefer small source-reader abstractions over a plugin system until there are
|
|
277
|
+
multiple real providers.
|