diff --git a/apps/v4/content/docs/(root)/about.mdx b/apps/v4/content/docs/(root)/about.mdx deleted file mode 100644 index ab523185c5..0000000000 --- a/apps/v4/content/docs/(root)/about.mdx +++ /dev/null @@ -1,20 +0,0 @@ ---- -title: About -description: Powered by amazing open source projects. ---- - -## About - -[ui.shadcn.com](https://ui.shadcn.com) is a project by [shadcn](https://shadcn.com). - -## Credits - -- [Radix UI](https://radix-ui.com) - For the primitives. -- [Vercel](https://vercel.com) - Where I host all my projects. -- [Shu Ding](https://shud.in) - The typography style is adapted from his work on Nextra. -- [Cal](https://cal.com) - Where I copied the styles for the first component: the `Button`. -- [cmdk](https://cmdk.paco.me) - For the `` component. - -## License - -MIT Β© [shadcn](https://shadcn.com) diff --git a/apps/v4/content/docs/(root)/react-19.mdx b/apps/v4/content/docs/(root)/react-19.mdx deleted file mode 100644 index 3c16bf1c66..0000000000 --- a/apps/v4/content/docs/(root)/react-19.mdx +++ /dev/null @@ -1,174 +0,0 @@ ---- -title: Next.js 15 + React 19 -description: Using shadcn/ui with Next.js 15 and React 19. ---- - - - **Update:** We have added full support for React 19 and Tailwind v4 in the - `canary` release. See the docs for [Tailwind v4](/docs/tailwind-v4) for more - information. - - - - **The following guide applies to any framework that supports React 19**. I - titled this page "Next.js 15 + React 19" to help people upgrading to Next.js - 15 find it. We are working with package maintainers to help upgrade to React - 19. - - -## TL;DR - -If you're using `npm`, you can install shadcn/ui dependencies with a flag. The `shadcn` CLI will prompt you to select a flag when you run it. No flags required for pnpm, bun, or yarn. - -See [Upgrade Status](#upgrade-status) for the status of React 19 support for each package. - -## What's happening? - -React 19 is now [rc](https://www.npmjs.com/package/react?activeTab=versions) and is [tested and supported in the latest Next.js 15 release](https://nextjs.org/blog/next-15#react-19). - -To support React 19, package maintainers will need to test and update their packages to include React 19 as a peer dependency. This is [already](https://github.com/radix-ui/primitives/pull/2952) [in](https://github.com/pacocoursey/cmdk/pull/318) [progress](https://github.com/emilkowalski/vaul/pull/498). - -```diff /^19.0/ -"peerDependencies": { -- "react": "^16.8 || ^17.0 || ^18.0", -+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0", -- "react-dom": "^16.8 || ^17.0 || ^18.0" -+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0" -}, -``` - - - You can check if a package lists React 19 as a peer dependency by running - `npm info peerDependencies`. - - -In the meantime, if you are installing a package that **does not** list React 19 as a peer dependency, you will see an error message like this: - -```bash -npm error code ERESOLVE -npm error ERESOLVE unable to resolve dependency tree -npm error -npm error While resolving: my-app@0.1.0 -npm error Found: react@19.0.0-rc-69d4b800-20241021 -npm error node_modules/react -npm error react@"19.0.0-rc-69d4b800-20241021" from the root project -``` - - - **Note:** This is npm only. PNPM and Bun will only show a silent warning. - - -## How to fix this - -### Solution 1: `--force` or `--legacy-peer-deps` - -You can force install a package with the `--force` or the `--legacy-peer-deps` flag. - -```bash -npm i --force - -npm i --legacy-peer-deps -``` - -This will install the package and ignore the peer dependency warnings. - - - - - What do the `--force` and `--legacy-peer-deps` flag do? - - - - - `--force`: Ignores and overrides any dependency conflicts, forcing the - installation of packages. - - `--legacy-peer-deps`: Skips strict peer dependency checks, allowing - installation of packages with unmet peer dependencies to avoid errors. - - - - - - -### Solution 2: Use React 18 - -You can downgrade `react` and `react-dom` to version 18, which is compatible with the package you are installing and upgrade when the dependency is updated. - -```bash -npm i react@18 react-dom@18 -``` - -Whichever solution you choose, make sure you test your app thoroughly to ensure -there are no regressions. - -## Using shadcn/ui on Next.js 15 - -### Using pnpm, bun, or yarn - -Follow the instructions in the [installation guide](/docs/installation/next) to install shadcn/ui. No flags are needed. - -### Using npm - -When you run `npx shadcn@latest init -d`, you will be prompted to select an option to resolve the peer dependency issues. - -```bash -It looks like you are using React 19. -Some packages may fail to install due to peer dependency issues (see https://ui.shadcn.com/react-19). - -? How would you like to proceed? β€Ί - Use arrow-keys. Return to submit. -❯ Use --force - Use --legacy-peer-deps -``` - -You can then run the command with the flag you choose. - -## Adding components - -The process for adding components is the same as above. Select a flag to resolve the peer dependency issues. - -**Remember to always test your app after installing new dependencies.** - -## Upgrade Status - -To make it easy for you track the progress of the upgrade, I've created a table below with React 19 support status for the shadcn/ui dependencies. - -- βœ… - Works with React 19 using npm, pnpm, and bun. -- 🚧 - Works with React 19 using pnpm and bun. Requires flag for npm. PR is in progress. - -| Package | Status | Note | -| ---------------------------------------------------------------------------------- | ------ | ----------------------------------------------------------- | -| [radix-ui](https://www.npmjs.com/package/@radix-ui/react-icons) | βœ… | | -| [lucide-react](https://www.npmjs.com/package/lucide-react) | βœ… | | -| [class-variance-authority](https://www.npmjs.com/package/class-variance-authority) | βœ… | Does not list React 19 as a peer dependency. | -| [tailwindcss-animate](https://www.npmjs.com/package/tailwindcss-animate) | βœ… | Does not list React 19 as a peer dependency. | -| [embla-carousel-react](https://www.npmjs.com/package/embla-carousel-react) | βœ… | | -| [recharts](https://www.npmjs.com/package/recharts) | βœ… | See note [below](#recharts) | -| [react-hook-form](https://www.npmjs.com/package/react-hook-form) | βœ… | | -| [react-resizable-panels](https://www.npmjs.com/package/react-resizable-panels) | βœ… | | -| [sonner](https://www.npmjs.com/package/sonner) | βœ… | | -| [react-day-picker](https://www.npmjs.com/package/react-day-picker) | βœ… | Works with flag for npm. Work to upgrade to v9 in progress. | -| [input-otp](https://www.npmjs.com/package/input-otp) | βœ… | | -| [vaul](https://www.npmjs.com/package/vaul) | βœ… | | -| [@radix-ui/react-icons](https://www.npmjs.com/package/@radix-ui/react-icons) | 🚧 | See [PR #194](https://github.com/radix-ui/icons/pull/194) | -| [cmdk](https://www.npmjs.com/package/cmdk) | βœ… | | - -If you have any questions, please [open an issue](https://github.com/shadcn/ui/issues) on GitHub. - -## Recharts - -To use recharts with React 19, you will need to override the `react-is` dependency. - - - -Add the following to your `package.json` - -```json title="package.json" -"overrides": { - "react-is": "^19.0.0-rc-69d4b800-20241021" -} -``` - -Note: the `react-is` version needs to match the version of React 19 you are using. The above is an example. - -Run `npm install --legacy-peer-deps` - - diff --git a/apps/v4/content/docs/(root)/styleguide.mdx b/apps/v4/content/docs/(root)/styleguide.mdx deleted file mode 100644 index 93c2dd5fe7..0000000000 --- a/apps/v4/content/docs/(root)/styleguide.mdx +++ /dev/null @@ -1,208 +0,0 @@ ---- -title: Styleguide -description: A styleguide for writing documentation in mdx. ---- - -The OpenAI API provides a simple interface to state-of-the-art AI models for text generation, natural language processing, computer vision, and more. This example generates text output from a prompt, as you might using ChatGPT. - -## Analyze image inputs - -You can provide image inputs to the model as well. Scan receipts, analyze screenshots, or find objects in the real world with [computer vision](/docs/installation/computer-vision). This is code in a `pre` tag and `npx` command in a `code` tag. - -```bash -npm install foo -``` - -```bash -npx shadcn@latest init -``` - -```bash -npx shadcn@latest add button -``` - -```tsx - -``` - -```tsx showLineNumbers -// With line numbers -export default function Home() { - return
Hello
-} -``` - -```tsx title="Button.tsx" -export default function Button({ children }: { children: React.ReactNode }) { - return -} -``` - -This is a code block with a title. - -## Line Numbers and Line Highlighting - -Draw attention to a particular line of code. - -```tsx {4} showLineNumbers -import { useFloating } from "@floating-ui/react" - -function MyComponent() { - const { refs, floatingStyles } = useFloating() - - return ( - <> -
-
- - ) -} -``` - -## Word Highlighting - -Draw attention to a particular word or series of characters. - -```tsx /floatingStyles/ -import { useFloating } from "@floating-ui/react" - -function MyComponent() { - const { refs, floatingStyles } = useFloating() - - return ( - <> -
-
- - ) -} -``` - -How - -```tsx title="apps/www/registry/registry-blocks.tsx" -export const blocks = [ - // ... - { - name: "dashboard-01", - author: "shadcn (https://ui.shadcn.com)", - title: "Dashboard", - description: "A simple dashboard with a hello world component.", - type: "registry:block", - registryDependencies: ["input", "button", "card"], - dependencies: ["zod"], - files: [ - { - path: "blocks/dashboard-01/page.tsx", - type: "registry:page", - target: "app/dashboard/page.tsx", - }, - { - path: "blocks/dashboard-01/components/hello-world.tsx", - type: "registry:component", - }, - { - path: "blocks/dashboard-01/components/example-card.tsx", - type: "registry:component", - }, - { - path: "blocks/dashboard-01/hooks/use-hello-world.ts", - type: "registry:hook", - }, - { - path: "blocks/dashboard-01/lib/format-date.ts", - type: "registry:lib", - }, - ], - categories: ["dashboard"], - }, -] -``` - -```txt -apps -└── web # Your app goes here. - β”œβ”€β”€ app - β”‚ └── page.tsx - β”œβ”€β”€ components - β”‚ └── login-form.tsx - β”œβ”€β”€ components.json - └── package.json -packages -└── ui # Your components and dependencies are installed here. - β”œβ”€β”€ src - β”‚ β”œβ”€β”€ components - β”‚ β”‚ └── button.tsx - β”‚ β”œβ”€β”€ hooks - β”‚ β”œβ”€β”€ lib - β”‚ β”‚ └── utils.ts - β”‚ └── styles - β”‚ └── globals.css - β”œβ”€β”€ components.json - └── package.json -package.json -turbo.json -``` - -```diff showLineNumbers -- @plugin 'tailwindcss-animate'; -+ @import "tw-animate-css"; -``` - -## CSS Variables - -```tsx /bg-background/ /text-foreground/ -
-``` - -To use CSS variables for theming set `tailwind.cssVariables` to `true` in your `components.json` file. - -```json {8} title="components.json" -{ - "style": "default", - "rsc": true, - "tailwind": { - "config": "", - "css": "app/globals.css", - "baseColor": "neutral", - "cssVariables": true - }, - "aliases": { - "components": "@/components", - "utils": "@/lib/utils", - "ui": "@/components/ui", - "lib": "@/lib", - "hooks": "@/hooks" - }, - "iconLibrary": "lucide" -} -``` - -## 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 {8} title="components.json" -{ - "style": "default", - "rsc": true, - "tailwind": { - "config": "", - "css": "app/globals.css", - "baseColor": "slate", - "cssVariables": false - }, - "aliases": { - "components": "@/components", - "utils": "@/lib/utils", - "ui": "@/components/ui", - "lib": "@/lib", - "hooks": "@/hooks" - }, - "iconLibrary": "lucide" -} -``` diff --git a/apps/v4/content/docs/(root)/tailwind-v4.mdx b/apps/v4/content/docs/(root)/tailwind-v4.mdx deleted file mode 100644 index 75e7c008f9..0000000000 --- a/apps/v4/content/docs/(root)/tailwind-v4.mdx +++ /dev/null @@ -1,333 +0,0 @@ ---- -title: Tailwind v4 -description: How to use shadcn/ui with Tailwind v4 and React 19. ---- - -It’s here! Tailwind v4 and React 19. Ready for you to try out. You can start using it today. - -## What's New - -- The CLI can now initialize projects with Tailwind v4. -- Full support for the new `@theme` directive and `@theme inline` option. -- All components are updated for Tailwind v4 and React 19. -- We’ve removed the forwardRefs and adjusted the types. -- Every primitive now has a `data-slot` attribute for styling. -- We've fixed and cleaned up the style of the components. -- We're deprecating the `toast` component in favor of `sonner`. -- Buttons now use the default cursor. -- We're deprecating the `default` style. New projects will use `new-york`. -- HSL colors are now converted to OKLCH. - -**Note: this is non-breaking. Your existing apps with Tailwind v3 and React 18 will still work. When you add new components, they'll still be in v3 and React 18 until you upgrade. Only new projects start with Tailwind v4 and React 19.** - -## Try It Out - -You can test Tailwind v4 + React 19 today using the `canary` release of the CLI. See the framework specific guides below for how to get started. - -
- - - Next.js - - -

Next.js

-
- - - Vite - - -

Vite

-
- - - - -

Laravel

-
- - - - -

React Router

-
- - - Astro - - -

Astro

-
- - - - -

TanStack Start

-
- - - Gatsby - - -

Gatsby

-
- - - React - - -

Manual

-
-
- -## Upgrade Your Project - - - **Important:** Before upgrading, please read the [Tailwind v4 Compatibility - Docs](https://tailwindcss.com/docs/compatibility) and make sure your project - is ready for the upgrade. Tailwind v4 uses bleeding-edge browser features and - is designed for modern browsers. - - -One of the major advantages of using `shadcn/ui` is that the code you end up with is exactly what you'd write yourself. There are no hidden abstractions. - -This means when a dependency has a new release, you can just follow the official upgrade paths. - -Here's how to upgrade your existing projects (full docs are on the way): - -### 1. Follow the Tailwind v4 Upgrade Guide - -- Upgrade to Tailwind v4 by following the official upgrade guide: https://tailwindcss.com/docs/upgrade-guide -- Use the `@tailwindcss/upgrade@next` codemod to remove deprecated utility classes and update tailwind config. - -### 2. Update your CSS variables - -The codemod will migrate your CSS variables as references under the `@theme` directive. - -```css showLineNumbers -@layer base { - :root { - --background: 0 0% 100%; - --foreground: 0 0% 3.9%; - } -} - -@theme { - --color-background: hsl(var(--background)); - --color-foreground: hsl(var(--foreground)); -} -``` - -This works. But to make it easier to work with colors and other variables, we'll need to move the `hsl` wrappers and use `@theme inline`. - -Here's how you do it: - -1. Move `:root` and `.dark` out of the `@layer` base. -2. Wrap the color values in `hsl()` -3. Add the `inline` option to `@theme` i.e `@theme inline` -4. Remove the `hsl()` wrappers from `@theme` - -```css showLineNumbers -:root { - --background: hsl(0 0% 100%); // <-- Wrap in hsl - --foreground: hsl(0 0% 3.9%); -} - -.dark { - --background: hsl(0 0% 3.9%); // <-- Wrap in hsl - --foreground: hsl(0 0% 98%); -} - -@theme inline { - --color-background: var(--background); // <-- Remove hsl - --color-foreground: var(--foreground); -} -``` - -This change makes it much simpler to access your theme variables in both utility classes and outside of CSS for eg. using color values in JavaScript. - -### 3. Update colors for charts - -Now that the theme colors come with `hsl()`, you can remove the wrapper in your `chartConfig`: - -```diff -const chartConfig = { - desktop: { - label: "Desktop", -- color: "hsl(var(--chart-1))", -+ color: "var(--chart-1)", - }, - mobile: { - label: "Mobile", -- color: "hsl(var(--chart-2))", -+ color: "var(--chart-2)", - }, -} satisfies ChartConfig -``` - -### 4. Use new `size-*` utility - -The new `size-*` utility (added in Tailwind v3.4), is now fully supported by `tailwind-merge`. You can replace `w-* h-*` with the new `size-*` utility: - -```diff -- w-4 h-4 -+ size-4 -``` - -### 5. Update your dependencies - -```bash -pnpm up "@radix-ui/*" cmdk lucide-react recharts tailwind-merge clsx --latest -``` - -### 6. Remove forwardRef - -You can use the `remove-forward-ref` codemod to migrate your `forwardRef` to props or manually update the primitives. - -For the codemod, see https://github.com/reactjs/react-codemod#remove-forward-ref. - -If you want to do it manually, here's how to do it step by step: - -1. Replace `React.forwardRef<...>` with `React.ComponentProps<...>` -2. Remove `ref={ref}` from the component. -3. Add a `data-slot` attribute. This will come in handy for styling with Tailwind. -4. You can optionally convert to a named function and remove the `displayName`. - -#### Before - -```tsx showLineNumbers -const AccordionItem = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)) -AccordionItem.displayName = "AccordionItem" -``` - -#### After - -```tsx showLineNumbers -function AccordionItem({ - className, - ...props -}: React.ComponentProps) { - return ( - - ) -} -``` - -## Changelog - -### March 19, 2025 - Deprecate `tailwindcss-animate` - -We've deprecated `tailwindcss-animate` in favor of `tw-animate-css`. - -New project will have `tw-animate-css` installed by default. - -For existing projects, follow the steps below to migrate. - -1. Remove `tailwindcss-animate` from your dependencies. -2. Remove the `@plugin 'tailwindcss-animate'` from your globals.css file. -3. Install `tw-animate-css` as a dev dependency. -4. Add the `@import "tw-animate-css"` to your globals.css file. - -```diff showLineNumbers -- @plugin 'tailwindcss-animate'; -+ @import "tw-animate-css"; -``` - -### March 12, 2025 - New Dark Mode Colors - -We've revisted the dark mode colors and updated them to be more accessible. - -If you're running an existing Tailwind v4 project (**not an upgraded one**[^1]), you can update your components to use the new dark mode colors by re-adding your components using the CLI[^2]. - - - -Commit any changes - -**The CLI will overwrite your existing components.** We recommend committing any changes you've made to your components before running the CLI. - -```bash -git add . -git commit -m "..." -``` - -Update components - -```bash -npx shadcn@latest add --all --overwrite -``` - -Update colors - -Update the dark mode colors in your `globals.css` file to new OKLCH colors. See the [Base Colors](/docs/theming#base-colors) reference for a list of colors. - -Review changes - -Review and re-apply any changes you made to your components. - - - -[^1]: Upgraded projects are not affected by this change. You can continue using the old dark mode colors. - -[^2]: Updating your components will overwrite your existing components.