Skip to content

How to update shadcn/ui components without losing your changes

There is no update command: use add --dry-run and --diff to see changes, --overwrite to take them, and Git to put your own edits back.

Updated 23 November 2026Tested with
  • shadcn 4.23.0
  • Tailwind CSS 4.3.5
  • Vite 8
  • React 19.3

There's no shadcn update command, because shadcn/ui components aren't a package. They're files in your repo. To update one, you ask the CLI for the latest version of that file and decide what to keep: npx shadcn@latest add button --diff shows what changed, and --overwrite replaces the file. With Git in between, you can take the update and keep your own edits.

We ran every command on this page in a shadcn 4.23 project where we had changed the button's corners to rounded-full.

1. See what would change

Start with a dry run. It lists which files would be created or overwritten and which dependencies would be added, and writes nothing:

Terminal
npx shadcn@latest add button --dry-run┌ shadcn add button (dry run)│├ Files (1) ~1 overwrite│ ~ src/components/ui/button.tsx  overwrite│⚠ 1 file will be overwritten.││ Run with --diff to view changes.└ Run without --dry-run to apply.

Then the diff. Lines marked - are in your file now; lines marked + are what the registry has:

Terminal
npx shadcn@latest add button --diff├ src/components/ui/button.tsx (overwrite)│ @@ -4,7 +4,7 @@│ -  "group/button inline-flex shrink-0 items-center justify-center rounded-full border …│ +  "group/button inline-flex shrink-0 items-center justify-center rounded-lg border …

Two things to know when you read it. Your own edits show up as changes too, since the CLI compares with the registry's current file, not with the version you once installed. And formatting counts: in our diff, three lines differed only in quote style inside a class string ("size-" against 'size-'), with nothing real changed.

--diff and --view work for one file at a time. For many components, run add --all --dry-run first to see which files the registry would touch.

2. Update and keep your edits

  1. Step 1: Commit first

    Start with a clean working tree so the update is the only change Git sees.

    Terminal
    git add -A && git commit -m "Before shadcn update"
  2. Step 2: Overwrite the file

    Terminal
    npx shadcn@latest add button --overwrite --yes✔ Checking registry.ℹ Updated 1 file:  - src/components/ui/button.tsx

    Without --overwrite the CLI asks before replacing an existing file, even with --yes; --yes only skips the initial confirmation.

  3. Step 3: Review the change and put your edits back

    git diff now shows upstream's changes and the loss of your own, side by side. Use git add -p to stage the hunks you want from upstream and git checkout -p to bring your own lines back. For a small edit like ours, that's two keystrokes per hunk.

    Terminal
    git diff --stat src/components/ui/button.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)

Dependencies get asked about too

When you add a component that depends on one you've edited, the CLI asks about the dependency. Adding dialog to our project (it uses button) stopped at:

Terminal
npx shadcn@latest add dialog? The file button.tsx already exists. Would you like to overwrite? › (y/N)✔ Created 1 file:  - src/components/ui/dialog.tsxℹ Skipped 1 file: (files might be identical, use --overwrite to overwrite)  - src/components/ui/button.tsx

Answering no (the default) kept our edited button and still created the dialog. In CI or scripts, that prompt blocks, so pipe an answer in or decide up front with --overwrite.

Moving to a new style or theme

Changing the look of every component at once is a different job: npx shadcn@latest apply --preset <code> re-applies a preset and reinstalls your components in its style. --only theme limits it to the CSS variables. It overwrites the component files, so the commit-first routine above matters even more.

Components from other registries

The same commands work for any registry item: npx shadcn@latest add @themesdev/hero-12 --diff compares one of our blocks with your copy. Each UI Pro release is listed in the changelog, and --diff shows whether a block you installed has changed since. Installing from a registry covers the setup.

Questions

How do I update all shadcn components at once?

npx shadcn@latest add --all --overwrite reinstalls every component from the registry. It also adds the ones you never installed, so we prefer naming the components you use: add button card dialog --overwrite.

Is shadcn diff gone?

The old shadcn diff command still exists but prints a deprecation notice. Use add <component> --diff.

How do I know which shadcn version I'm on?

There's no version per component. npx shadcn@latest info shows your style, base library and preset, which decide what add gives you.

Was this page helpful?

Still stuck? We answer every message ourselves. Write to us

This page is built from UI Pro parts: the docs article block (docs-quernly) with the code, terminal, install command, steps, contents and feedback components. They ship in the next UI Pro release; the install command and the contents rail are free.