Until now, using shadcn/ui in a monorepo was a bit of a pain. You could add components using the CLI, but you had to manage where the components were installed and manually fix import paths. With the new monorepo support in the CLI, we’ve made it a lot easier to use shadcn/ui in a monorepo. The CLI now understands the monorepo structure and will install the components, dependencies and registry dependencies to the correct paths and handle imports for you.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/shadcn-ui/ui/llms.txt
Use this file to discover all available pages before exploring further.
Getting started
To create a new monorepo project, run the
init command. You will be prompted
to select the type of project you are creating.This will create a new monorepo project with two workspaces:
web and ui,
and Turborepo as the build system.The CLI will figure out what type of component you are adding and install the
correct files to the correct path.
For example, if you run
npx shadcn@latest add button, the CLI will install the button component under packages/ui and update the import path for components in apps/web.If you run
npx shadcn@latest add login-01, the CLI will install the button, label, input and card components under packages/ui and the login-form component under apps/web/components.File Structure
When you create a new monorepo project, the CLI will create the following file structure:Requirements
-
Every workspace must have a
components.jsonfile. Apackage.jsonfile tells npm how to install the dependencies. Acomponents.jsonfile tells the CLI how and where to install components. -
The
components.jsonfile must properly define aliases for the workspace. This tells the CLI how to import components, hooks, utilities, etc.
apps/web/components.json
packages/ui/components.json
-
Ensure you have the same
style,iconLibraryandbaseColorin bothcomponents.jsonfiles. -
For Tailwind CSS v4, leave the
tailwindconfig empty in thecomponents.jsonfile.