--- title: June 2023 - New CLI, Styles and more description: Complete CLI rewrite with new styles, theming options, and more. date: 2023-06-22 --- I have a lot of updates to share with you today: - [**New CLI**](#new-cli) - Rewrote the CLI from scratch. You can now add components, dependencies and configure import paths. - [**Theming**](#theming-with-css-variables-or-tailwind-colors) - Choose between using CSS variables or Tailwind CSS utility classes for theming. - [**Base color**](#base-color) - Configure the base color for your project. This will be used to generate the default color palette for your components. - [**React Server Components**](#react-server-components) - Opt out of using React Server Components. The CLI will automatically append or remove the `use client` directive. - [**Styles**](#styles) - Introducing a new concept called _Style_. A style comes with its own set of components, animations, icons and more. - [**Exit animations**](#exit-animations) - Added exit animations to all components. - [**Other updates**](#other-updates) - New `icon` button size, updated `sheet` component and more. - [**Updating your project**](#updating-your-project) - How to update your project to get the latest changes. --- ### New CLI I've been working on a new CLI for the past few weeks. It's a complete rewrite. It comes with a lot of new features and improvements. ### `init` ```bash npx shadcn@latest init ``` When you run the `init` command, you will be asked a few questions to configure `components.json`: ```txt showLineNumbers Which style would you like to use? › Default Which color would you like to use as base color? › Slate Where is your global CSS file? › › app/globals.css Do you want to use CSS variables for colors? › no / yes Where is your tailwind.config.js located? › tailwind.config.js Configure the import alias for components: › @/components Configure the import alias for utils: › @/lib/utils Are you using React Server Components? › no / yes ``` This file contains all the information about your components: where to install them, the import paths, how they are styled...etc. You can use this file to change the import path of a component, set a baseColor or change the styling method. ```json title="components.json" showLineNumbers { "style": "default", "tailwind": { "config": "tailwind.config.ts", "css": "src/app/globals.css", "baseColor": "zinc", "cssVariables": true }, "rsc": false, "aliases": { "utils": "~/lib/utils", "components": "~/components" } } ``` This means you can now use the CLI with any directory structure including `src` and `app` directories. ### `add` ```bash npx shadcn@latest add ``` The `add` command is now much more capable. You can now add UI components but also import more complex components (coming soon). The CLI will automatically resolve all components and dependencies, format them based on your custom config and add them to your project. ### `diff` (experimental) ```bash npx shadcn diff ``` We're also introducing a new `diff` command to help you keep track of upstream updates. You can use this command to see what has changed in the upstream repository and update your project accordingly. Run the `diff` command to get a list of components that have updates available: ```bash npx shadcn diff ``` ```txt The following components have updates available: - button - /path/to/my-app/components/ui/button.tsx - toast - /path/to/my-app/components/ui/use-toast.ts - /path/to/my-app/components/ui/toaster.tsx ``` Then run `diff [component]` to see the changes: ```bash npx shadcn diff alert ``` ```diff /pl-12/ const alertVariants = cva( - "relative w-full rounded-lg border", + "relative w-full pl-12 rounded-lg border" ) ``` --- ### Theming with CSS Variables or Tailwind Colors You can choose between using CSS variables or Tailwind CSS utility classes for theming. When you add new components, the CLI will automatically use the correct theming methods based on your `components.json` configuration. #### Utility classes ```tsx /bg-zinc-950/ /text-zinc-50/ /dark:bg-white/ /dark:text-zinc-950/
``` To use utility classes for theming set `tailwind.cssVariables` to `false` in your `components.json` file. ```json {6} title="components.json" showLineNumbers { "tailwind": { "config": "tailwind.config.js", "css": "app/globals.css", "baseColor": "slate", "cssVariables": false } } ``` #### CSS Variables ```tsx /bg-background/ /text-foreground/ ``` To use CSS variables classes for theming set `tailwind.cssVariables` to `true` in your `components.json` file. ```json {6} title="components.json" showLineNumbers { "tailwind": { "config": "tailwind.config.js", "css": "app/globals.css", "baseColor": "slate", "cssVariables": true } } ``` --- ### Base color You can now configure the base color for your project. This will be used to generate the default color palette for your components. ```json {5} title="components.json" showLineNumbers { "tailwind": { "config": "tailwind.config.js", "css": "app/globals.css", "baseColor": "zinc", "cssVariables": false } } ``` Choose between `gray`, `neutral`, `slate`, `stone` or `zinc`. If you have `cssVariables` set to `true`, we will set the base colors as CSS variables in your `globals.css` file. If you have `cssVariables` set to `false`, we will inline the Tailwind CSS utility classes in your components. --- ### React Server Components If you're using a framework that does not support React Server Components, you can now opt out by setting `rsc` to `false`. We will automatically append or remove the `use client` directive when adding components. ```json title="components.json" showLineNumbers { "rsc": false } ``` --- ### Styles We are introducing a new concept called _Style_. _You can think of style as the visual foundation: shapes, icons, animations & typography._ A style comes with its own set of components, animations, icons and more. We are shipping two styles: `default` and `new-york` (with more coming soon).