You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/v4/content/docs/(root)/cli.mdx
+62-12Lines changed: 62 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,42 +5,44 @@ description: Use the shadcn CLI to add components to your project.
5
5
6
6
## init
7
7
8
-
Use the `init` command to initialize configuration and dependencies for a new project.
8
+
Use the `init` command to initialize configuration and dependencies for an existing project, or create a new project with `--name`.
9
9
10
10
The `init` command installs dependencies, adds the `cn` util and configures CSS variables for the project.
11
11
12
+
For preset reapplication in an existing project, use [`apply`](#apply) when you want to overwrite preset-driven files and reinstall detected UI components. Use `init --force --no-reinstall` when you want to update config and CSS without reinstalling existing components.
-d, --defaults use default configuration: --template=next --preset=base-nova (default: false)
33
36
-f, --force force overwrite of existing configuration. (default: false)
34
37
-c, --cwd <cwd> the working directory. defaults to the current directory.
38
+
-n, --name <name> the name for the new project.
35
39
-s, --silent mute output. (default: false)
36
-
--monorepo scaffold a monorepo project.
37
-
--no-monorepo skip the monorepo prompt.
38
-
--reinstall re-install existing UI components.
39
-
--no-reinstall do not re-install existing UI components.
40
-
--rtl enable RTL support.
41
-
--no-rtl disable RTL support.
42
40
--css-variables use css variables for theming. (default: true)
43
41
--no-css-variables do not use css variables for theming.
42
+
--rtl enable RTL support.
43
+
--no-rtl disable RTL support.
44
+
--reinstall re-install existing UI components.
45
+
--no-reinstall do not re-install existing UI components.
44
46
-h, --help display helpforcommand
45
47
```
46
48
@@ -52,6 +54,54 @@ npx shadcn@latest create
52
54
53
55
---
54
56
57
+
## apply
58
+
59
+
Use the `apply` command to apply a preset to an existing project.
60
+
61
+
`apply` overwrites preset-driven config, fonts, CSS variables, and detected installed UI components. Commit or stash your changes before continuing so you can easily go back.
62
+
63
+
`apply` requires an existing `components.json`. If your project is not initialized yet, run `shadcn init --preset <preset>` first.
64
+
65
+
```bash
66
+
npx shadcn@latest apply --preset a2r6bw
67
+
```
68
+
69
+
You can also pass the preset as a positional argument:
70
+
71
+
```bash
72
+
npx shadcn@latest apply a2r6bw
73
+
```
74
+
75
+
Named presets work the same way:
76
+
77
+
```bash
78
+
npx shadcn@latest apply lyra
79
+
```
80
+
81
+
If no preset is provided, the CLI offers to open the custom preset builder on `ui.shadcn.com/create`.
82
+
83
+
Use `apply` for overwrite/reinstall flows. If you want to refresh config and CSS without reinstalling existing components, use `init --force --no-reinstall` instead.
Copy file name to clipboardExpand all lines: packages/shadcn/README.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,16 @@ The `init` command installs dependencies, adds the `cn` util, configures Tailwin
20
20
npx shadcn init
21
21
```
22
22
23
+
## apply
24
+
25
+
Use the `apply` command to apply a preset to an existing project.
26
+
27
+
The `apply` command overwrites the current preset configuration, reinstalls detected UI components, and updates fonts and CSS variables to match the new preset.
28
+
29
+
```bash
30
+
npx shadcn apply --preset a2r6bw
31
+
```
32
+
23
33
## add
24
34
25
35
Use the `add` command to add components to your project.
0 commit comments