snapshot of https://github.com/shadcn-ui/ui.git (main, 2026-09-15; blobs > 131072B omitted)
This commit is contained in:
252
apps/v4/content/docs/installation/astro.mdx
Normal file
252
apps/v4/content/docs/installation/astro.mdx
Normal file
@@ -0,0 +1,252 @@
|
||||
---
|
||||
title: Astro
|
||||
description: Install and configure shadcn/ui for Astro.
|
||||
---
|
||||
|
||||
Choose the setup that matches your starting point.
|
||||
|
||||
<div className="mt-6 grid gap-4 sm:grid-cols-3 sm:gap-6">
|
||||
<LinkedCard
|
||||
href="#scaffold-with-create"
|
||||
className="items-start gap-1 p-6 text-sm md:p-6"
|
||||
>
|
||||
<div className="font-medium">Use shadcn/create</div>
|
||||
<div className="leading-relaxed text-muted-foreground">
|
||||
Build your preset and generate an Astro project command.
|
||||
</div>
|
||||
</LinkedCard>
|
||||
<LinkedCard
|
||||
href="#scaffold-with-cli"
|
||||
className="items-start gap-1 p-6 text-sm md:p-6"
|
||||
>
|
||||
<div className="font-medium">Use the CLI</div>
|
||||
<div className="leading-relaxed text-muted-foreground">
|
||||
Scaffold a new Astro project directly from the terminal.
|
||||
</div>
|
||||
</LinkedCard>
|
||||
<LinkedCard
|
||||
href="#existing-astro-project"
|
||||
className="items-start gap-1 p-6 text-sm md:p-6"
|
||||
>
|
||||
<div className="font-medium">Existing Project</div>
|
||||
<div className="leading-relaxed text-muted-foreground">
|
||||
Configure shadcn/ui manually in an existing Astro project.
|
||||
</div>
|
||||
</LinkedCard>
|
||||
</div>
|
||||
|
||||
<div id="scaffold-with-create" className="scroll-mt-24" />
|
||||
## Use shadcn/create
|
||||
|
||||
<Steps>
|
||||
|
||||
### Build Your Preset
|
||||
|
||||
Open [shadcn/create](/create?template=astro) and build your preset visually. Choose your style, colors, fonts, icons, and more.
|
||||
|
||||
<Button asChild size="sm">
|
||||
<Link
|
||||
href="/create?template=astro"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="mt-6 no-underline!"
|
||||
>
|
||||
Open shadcn/create
|
||||
</Link>
|
||||
</Button>
|
||||
|
||||
### Create Project
|
||||
|
||||
Click `Create Project`, choose your package manager, and copy the generated command.
|
||||
|
||||
The generated command will look similar to this:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest init --preset [CODE] --template astro
|
||||
```
|
||||
|
||||
The exact command will include your selected options such as `--base`, `--monorepo`, or `--rtl`.
|
||||
|
||||
### Add Components
|
||||
|
||||
Add the `Card` component to your project:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add card
|
||||
```
|
||||
|
||||
If you created a monorepo, run the command from `apps/web` or specify the workspace from the repo root:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add card -c apps/web
|
||||
```
|
||||
|
||||
The command above will add the `Card` component to your project. You can then import it like this:
|
||||
|
||||
```astro title="src/pages/index.astro" showLineNumbers
|
||||
---
|
||||
import Layout from "@/layouts/main.astro"
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card"
|
||||
---
|
||||
|
||||
<Layout>
|
||||
<Card className="max-w-sm">
|
||||
<CardHeader>
|
||||
<CardTitle>Project Overview</CardTitle>
|
||||
<CardDescription>
|
||||
Track progress and recent activity for your Astro app.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
Your design system is ready. Start building your next component.
|
||||
</CardContent>
|
||||
</Card>
|
||||
</Layout>
|
||||
```
|
||||
|
||||
If you created a monorepo, update `apps/web/src/pages/index.astro` and import from `@workspace/ui/components/card` instead. The monorepo layout at `apps/web/src/layouts/main.astro` already imports `@workspace/ui/globals.css` for you.
|
||||
|
||||
</Steps>
|
||||
|
||||
<div id="scaffold-with-cli" className="scroll-mt-24" />
|
||||
## Use the CLI
|
||||
|
||||
<Steps>
|
||||
|
||||
### Create Project
|
||||
|
||||
Run the `init` command to scaffold a new Astro project. Follow the prompts to configure your project: base, preset, monorepo, and more.
|
||||
|
||||
```bash
|
||||
npx shadcn@latest init -t astro
|
||||
```
|
||||
|
||||
**For a monorepo project, use `--monorepo` flag:**
|
||||
|
||||
```bash
|
||||
npx shadcn@latest init -t astro --monorepo
|
||||
```
|
||||
|
||||
### Add Components
|
||||
|
||||
Add the `Card` component to your project:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add card
|
||||
```
|
||||
|
||||
If you created a monorepo, run the command from `apps/web` or specify the workspace from the repo root:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add card -c apps/web
|
||||
```
|
||||
|
||||
The command above will add the `Card` component to your project. You can then import it like this:
|
||||
|
||||
```astro title="src/pages/index.astro" showLineNumbers
|
||||
---
|
||||
import Layout from "@/layouts/main.astro"
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card"
|
||||
---
|
||||
|
||||
<Layout>
|
||||
<Card className="max-w-sm">
|
||||
<CardHeader>
|
||||
<CardTitle>Project Overview</CardTitle>
|
||||
<CardDescription>
|
||||
Track progress and recent activity for your Astro app.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
Your design system is ready. Start building your next component.
|
||||
</CardContent>
|
||||
</Card>
|
||||
</Layout>
|
||||
```
|
||||
|
||||
If you created a monorepo, update `apps/web/src/pages/index.astro` and import from `@workspace/ui/components/card` instead. The monorepo layout at `apps/web/src/layouts/main.astro` already imports `@workspace/ui/globals.css` for you.
|
||||
|
||||
</Steps>
|
||||
|
||||
<div id="existing-astro-project" className="scroll-mt-24" />
|
||||
## Existing Project
|
||||
|
||||
<Steps>
|
||||
|
||||
### Create Project
|
||||
|
||||
If you need a new Astro project, create one first. Otherwise, skip this step.
|
||||
|
||||
```bash
|
||||
npm create astro@latest astro-app -- --template with-tailwindcss --install --add react --git
|
||||
```
|
||||
|
||||
This command sets up Tailwind CSS and the React integration for you. If you're adding shadcn/ui to an older or custom Astro app, make sure both are configured before continuing.
|
||||
|
||||
The Tailwind starter loads your global stylesheet through `src/layouts/main.astro`. Keep that layout in place, or make sure your page imports `@/styles/global.css`.
|
||||
|
||||
### Edit tsconfig.json file
|
||||
|
||||
If your project already has the `@/*` alias configured, skip this step.
|
||||
|
||||
Add the following code to the `tsconfig.json` file to resolve paths:
|
||||
|
||||
```ts title="tsconfig.json" {4-9} showLineNumbers
|
||||
{
|
||||
"compilerOptions": {
|
||||
// ...
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": [
|
||||
"./src/*"
|
||||
]
|
||||
}
|
||||
// ...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Run the CLI
|
||||
|
||||
Run the `shadcn` init command to set up your project:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest init
|
||||
```
|
||||
|
||||
### Add Components
|
||||
|
||||
You can now start adding components to your project.
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add button
|
||||
```
|
||||
|
||||
The command above will add the `Button` component to your project. You can then import it like this:
|
||||
|
||||
```astro title="src/pages/index.astro" showLineNumbers
|
||||
---
|
||||
import Layout from "@/layouts/main.astro"
|
||||
import { Button } from "@/components/ui/button"
|
||||
---
|
||||
|
||||
<Layout>
|
||||
<div class="grid h-screen place-items-center content-center">
|
||||
<Button>Button</Button>
|
||||
</div>
|
||||
</Layout>
|
||||
```
|
||||
|
||||
</Steps>
|
||||
109
apps/v4/content/docs/installation/gatsby.mdx
Normal file
109
apps/v4/content/docs/installation/gatsby.mdx
Normal file
@@ -0,0 +1,109 @@
|
||||
---
|
||||
title: Gatsby
|
||||
description: Install and configure shadcn/ui for Gatsby.
|
||||
---
|
||||
|
||||
<Callout className="mb-6 border-blue-600 bg-blue-50 dark:border-blue-900 dark:bg-blue-950 [&_code]:bg-blue-100 dark:[&_code]:bg-blue-900">
|
||||
**Note:** This guide is for Gatsby with Tailwind CSS v3. For new projects, we
|
||||
recommend using one of the other frameworks that support Tailwind CSS v4.
|
||||
</Callout>
|
||||
|
||||
<Steps>
|
||||
|
||||
### Create project
|
||||
|
||||
Start by creating a new Gatsby project using `create-gatsby`:
|
||||
|
||||
```bash
|
||||
npm init gatsby
|
||||
```
|
||||
|
||||
### Configure your Gatsby project to use TypeScript and Tailwind CSS
|
||||
|
||||
You will be asked a few questions to configure your project:
|
||||
|
||||
```txt showLineNumbers
|
||||
✔ What would you like to call your site?
|
||||
· your-app-name
|
||||
✔ What would you like to name the folder where your site will be created?
|
||||
· your-app-name
|
||||
✔ Will you be using JavaScript or TypeScript?
|
||||
· TypeScript
|
||||
✔ Will you be using a CMS?
|
||||
· Choose whatever you want
|
||||
✔ Would you like to install a styling system?
|
||||
· Tailwind CSS
|
||||
✔ Would you like to install additional features with other plugins?
|
||||
· Choose whatever you want
|
||||
✔ Shall we do this? (Y/n) · Yes
|
||||
```
|
||||
|
||||
### Edit tsconfig.json file
|
||||
|
||||
Add the following code to the `tsconfig.json` file to resolve paths:
|
||||
|
||||
```ts {4-9} showLineNumbers
|
||||
{
|
||||
"compilerOptions": {
|
||||
// ...
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": [
|
||||
"./src/*"
|
||||
]
|
||||
}
|
||||
// ...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Create gatsby-node.ts file
|
||||
|
||||
Create a `gatsby-node.ts` file at the root of your project if it doesn’t already exist, and add the code below to the `gatsby-node` file so your app can resolve paths:
|
||||
|
||||
```ts
|
||||
import * as path from "path"
|
||||
|
||||
export const onCreateWebpackConfig = ({ actions }) => {
|
||||
actions.setWebpackConfig({
|
||||
resolve: {
|
||||
alias: {
|
||||
"@/components": path.resolve(__dirname, "src/components"),
|
||||
"@/lib/utils": path.resolve(__dirname, "src/lib/utils"),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
### Run the CLI
|
||||
|
||||
Run the `shadcn` init command to set up your project:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest init
|
||||
```
|
||||
|
||||
### That's it
|
||||
|
||||
You can now start adding components to your project.
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add button
|
||||
```
|
||||
|
||||
The command above will add the `Button` component to your project. You can then import it like this:
|
||||
|
||||
```tsx {1,6} showLineNumbers
|
||||
import { Button } from "@/components/ui/button"
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<div>
|
||||
<Button>Click me</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
</Steps>
|
||||
174
apps/v4/content/docs/installation/index.mdx
Normal file
174
apps/v4/content/docs/installation/index.mdx
Normal file
@@ -0,0 +1,174 @@
|
||||
---
|
||||
title: Installation
|
||||
description: How to install dependencies and structure your app.
|
||||
---
|
||||
|
||||
<Callout className="mb-6 border-emerald-600 bg-emerald-100 dark:border-emerald-400 dark:bg-emerald-900">
|
||||
|
||||
**Recommended for new projects:** Use [shadcn/create](/create) to build your preset visually and generate the right setup command for your framework.
|
||||
|
||||
</Callout>
|
||||
|
||||
Choose the setup that matches your starting point.
|
||||
|
||||
<div className="mt-6 grid gap-4 sm:grid-cols-3 sm:gap-6">
|
||||
<LinkedCard
|
||||
href="#use-create"
|
||||
className="items-start gap-1 p-6 text-sm md:p-6"
|
||||
>
|
||||
<div className="font-medium">Use shadcn/create</div>
|
||||
<div className="leading-relaxed text-muted-foreground">
|
||||
Build your preset visually and generate a setup command.
|
||||
</div>
|
||||
</LinkedCard>
|
||||
<LinkedCard href="#use-cli" className="items-start gap-1 p-6 text-sm md:p-6">
|
||||
<div className="font-medium">Use the CLI</div>
|
||||
<div className="leading-relaxed text-muted-foreground">
|
||||
Scaffold a supported template directly from the terminal.
|
||||
</div>
|
||||
</LinkedCard>
|
||||
<LinkedCard
|
||||
href="#existing-project"
|
||||
className="items-start gap-1 p-6 text-sm md:p-6"
|
||||
>
|
||||
<div className="font-medium">Existing Project</div>
|
||||
<div className="leading-relaxed text-muted-foreground">
|
||||
Add shadcn/ui to an app you already created.
|
||||
</div>
|
||||
</LinkedCard>
|
||||
</div>
|
||||
|
||||
<div id="use-create" className="scroll-mt-24" />
|
||||
## Use shadcn/create
|
||||
|
||||
Build your preset visually, preview your choices, and generate a framework-specific setup command.
|
||||
|
||||
<Button asChild size="sm">
|
||||
<Link
|
||||
href="/create"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="mt-6 no-underline!"
|
||||
>
|
||||
Open shadcn/create
|
||||
</Link>
|
||||
</Button>
|
||||
|
||||
Available for Next.js, Vite, Laravel, React Router, Astro, and TanStack Start.
|
||||
|
||||
<div id="use-cli" className="scroll-mt-24" />
|
||||
## Use the CLI
|
||||
|
||||
Use the CLI to scaffold a new project directly from the terminal:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest init -t [framework]
|
||||
```
|
||||
|
||||
Supported templates: `next`, `vite`, `start`, `react-router`, and `astro`.
|
||||
|
||||
For Laravel, create the app first with `laravel new`, then run `npx shadcn@latest init`.
|
||||
|
||||
<div id="existing-project" className="scroll-mt-24" />
|
||||
## Existing Project
|
||||
|
||||
Each framework guide includes an `Existing Project` section with the manual setup steps for that framework.
|
||||
|
||||
Pick your framework below and follow that path.
|
||||
|
||||
## Choose Your Framework
|
||||
|
||||
For Laravel, start with `laravel new` before using `shadcn/create` or `shadcn init`.
|
||||
|
||||
<div className="mt-8 grid gap-4 sm:grid-cols-2 sm:gap-6">
|
||||
<LinkedCard href="/docs/installation/next">
|
||||
<svg
|
||||
role="img"
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
className="h-10 w-10"
|
||||
fill="currentColor"
|
||||
>
|
||||
<title>Next.js</title>
|
||||
<path d="M11.5725 0c-.1763 0-.3098.0013-.3584.0067-.0516.0053-.2159.021-.3636.0328-3.4088.3073-6.6017 2.1463-8.624 4.9728C1.1004 6.584.3802 8.3666.1082 10.255c-.0962.659-.108.8537-.108 1.7474s.012 1.0884.108 1.7476c.652 4.506 3.8591 8.2919 8.2087 9.6945.7789.2511 1.6.4223 2.5337.5255.3636.04 1.9354.04 2.299 0 1.6117-.1783 2.9772-.577 4.3237-1.2643.2065-.1056.2464-.1337.2183-.1573-.0188-.0139-.8987-1.1938-1.9543-2.62l-1.919-2.592-2.4047-3.5583c-1.3231-1.9564-2.4117-3.556-2.4211-3.556-.0094-.0026-.0187 1.5787-.0235 3.509-.0067 3.3802-.0093 3.5162-.0516 3.596-.061.115-.108.1618-.2064.2134-.075.0374-.1408.0445-.495.0445h-.406l-.1078-.068a.4383.4383 0 01-.1572-.1712l-.0493-.1056.0053-4.703.0067-4.7054.0726-.0915c.0376-.0493.1174-.1125.1736-.143.0962-.047.1338-.0517.5396-.0517.4787 0 .5584.0187.6827.1547.0353.0377 1.3373 1.9987 2.895 4.3608a10760.433 10760.433 0 004.7344 7.1706l1.9002 2.8782.096-.0633c.8518-.5536 1.7525-1.3418 2.4657-2.1627 1.5179-1.7429 2.4963-3.868 2.8247-6.134.0961-.6591.1078-.854.1078-1.7475 0-.8937-.012-1.0884-.1078-1.7476-.6522-4.506-3.8592-8.2919-8.2087-9.6945-.7672-.2487-1.5836-.42-2.4985-.5232-.169-.0176-1.0835-.0366-1.6123-.037zm4.0685 7.217c.3473 0 .4082.0053.4857.047.1127.0562.204.1642.237.2767.0186.061.0234 1.3653.0186 4.3044l-.0067 4.2175-.7436-1.14-.7461-1.14v-3.066c0-1.982.0093-3.0963.0234-3.1502.0375-.1313.1196-.2346.2323-.2955.0961-.0494.1313-.054.4997-.054z" />
|
||||
</svg>
|
||||
<p className="mt-2 font-medium">Next.js</p>
|
||||
</LinkedCard>
|
||||
<LinkedCard href="/docs/installation/vite">
|
||||
<svg
|
||||
role="img"
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
className="h-10 w-10"
|
||||
fill="currentColor"
|
||||
>
|
||||
<title>Vite</title>
|
||||
<path d="m8.286 10.578.512-8.657a.306.306 0 0 1 .247-.282L17.377.006a.306.306 0 0 1 .353.385l-1.558 5.403a.306.306 0 0 0 .352.385l2.388-.46a.306.306 0 0 1 .332.438l-6.79 13.55-.123.19a.294.294 0 0 1-.252.14c-.177 0-.35-.152-.305-.369l1.095-5.301a.306.306 0 0 0-.388-.355l-1.433.435a.306.306 0 0 1-.389-.354l.69-3.375a.306.306 0 0 0-.37-.36l-2.32.536a.306.306 0 0 1-.374-.316zm14.976-7.926L17.284 3.74l-.544 1.887 2.077-.4a.8.8 0 0 1 .84.369.8.8 0 0 1 .034.783L12.9 19.93l-.013.025-.015.023-.122.19a.801.801 0 0 1-.672.37.826.826 0 0 1-.634-.302.8.8 0 0 1-.16-.67l1.029-4.981-1.12.34a.81.81 0 0 1-.86-.262.802.802 0 0 1-.165-.67l.63-3.08-2.027.468a.808.808 0 0 1-.768-.233.81.81 0 0 1-.217-.6l.389-6.57-7.44-1.33a.612.612 0 0 0-.64.906L11.58 23.691a.612.612 0 0 0 1.066-.004l11.26-20.135a.612.612 0 0 0-.644-.9z" />
|
||||
</svg>
|
||||
<p className="mt-2 font-medium">Vite</p>
|
||||
</LinkedCard>
|
||||
|
||||
<LinkedCard href="/docs/installation/tanstack">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
className="h-10 w-10"
|
||||
fill="currentColor"
|
||||
>
|
||||
<path d="M6.93 13.688a.343.343 0 0 1 .468.132l.063.106c.48.851.98 1.66 1.5 2.426a35.65 35.65 0 0 0 2.074 2.742.345.345 0 0 1-.039.484l-.074.066c-2.543 2.223-4.191 2.665-4.953 1.333-.746-1.305-.477-3.672.808-7.11a.344.344 0 0 1 .153-.18ZM17.75 16.3a.34.34 0 0 1 .395.27l.02.1c.628 3.286.187 4.93-1.325 4.93-1.48 0-3.36-1.402-5.649-4.203a.327.327 0 0 1-.074-.222c0-.188.156-.34.344-.34h.121a32.984 32.984 0 0 0 2.809-.098c1.07-.086 2.191-.23 3.359-.437zm.871-6.977a.353.353 0 0 1 .445-.21l.102.034c3.262 1.11 4.504 2.332 3.719 3.664-.766 1.305-2.993 2.254-6.684 2.848a.362.362 0 0 1-.238-.047.343.343 0 0 1-.125-.476l.062-.106a34.07 34.07 0 0 0 1.367-2.523c.477-.989.93-2.051 1.352-3.184zM7.797 8.34a.362.362 0 0 1 .238.047.343.343 0 0 1 .125.476l-.062.106a34.088 34.088 0 0 0-1.367 2.523c-.477.988-.93 2.051-1.352 3.184a.353.353 0 0 1-.445.21l-.102-.034C1.57 13.742.328 12.52 1.113 11.188 1.88 9.883 4.106 8.934 7.797 8.34Zm5.281-3.984c2.543-2.223 4.192-2.664 4.953-1.332.746 1.304.477 3.671-.808 7.109a.344.344 0 0 1-.153.18.343.343 0 0 1-.468-.133l-.063-.106a34.64 34.64 0 0 0-1.5-2.426 35.65 35.65 0 0 0-2.074-2.742.345.345 0 0 1 .039-.484ZM7.285 2.274c1.48 0 3.364 1.402 5.649 4.203a.349.349 0 0 1 .078.218.348.348 0 0 1-.348.344l-.117-.004a34.584 34.584 0 0 0-2.809.102 35.54 35.54 0 0 0-3.363.437.343.343 0 0 1-.394-.273l-.02-.098c-.629-3.285-.188-4.93 1.324-4.93Zm2.871 5.812h3.688a.638.638 0 0 1 .55.316l1.848 3.22a.644.644 0 0 1 0 .628l-1.847 3.223a.638.638 0 0 1-.551.316h-3.688a.627.627 0 0 1-.547-.316L7.758 12.25a.644.644 0 0 1 0-.629L9.61 8.402a.627.627 0 0 1 .546-.316Zm3.23.793a.638.638 0 0 1 .552.316l1.39 2.426a.644.644 0 0 1 0 .629l-1.39 2.43a.638.638 0 0 1-.551.316h-2.774a.627.627 0 0 1-.546-.316l-1.395-2.43a.644.644 0 0 1 0-.629l1.395-2.426a.627.627 0 0 1 .546-.316Zm-.491.867h-1.79a.624.624 0 0 0-.546.316l-.899 1.56a.644.644 0 0 0 0 .628l.899 1.563a.632.632 0 0 0 .547.316h1.789a.632.632 0 0 0 .547-.316l.898-1.563a.644.644 0 0 0 0-.629l-.898-1.558a.624.624 0 0 0-.547-.317Zm-.477.828c.227 0 .438.121.547.317l.422.73a.625.625 0 0 1 0 .629l-.422.734a.627.627 0 0 1-.547.317h-.836a.632.632 0 0 1-.547-.317l-.422-.734a.625.625 0 0 1 0-.629l.422-.73a.632.632 0 0 1 .547-.317zm-.418.817a.548.548 0 0 0-.473.273.547.547 0 0 0 0 .547.544.544 0 0 0 .473.27.544.544 0 0 0 .473-.27.547.547 0 0 0 0-.547.548.548 0 0 0-.473-.273Zm-4.422.546h.98M18.98 7.75c.391-1.895.477-3.344.223-4.398-.148-.63-.422-1.137-.84-1.508-.441-.39-1-.582-1.625-.582-1.035 0-2.12.472-3.281 1.367a14.9 14.9 0 0 0-1.473 1.316 1.206 1.206 0 0 0-.136-.144c-1.446-1.285-2.66-2.082-3.7-2.39-.617-.184-1.195-.2-1.722-.024-.559.187-1.004.574-1.317 1.117-.515.894-.652 2.074-.46 3.527.078.59.214 1.235.402 1.934a1.119 1.119 0 0 0-.215.047C3.008 8.62 1.71 9.269.926 10.015c-.465.442-.77.938-.883 1.481-.113.578 0 1.156.312 1.7.516.894 1.465 1.597 2.817 2.155.543.223 1.156.426 1.844.61a1.023 1.023 0 0 0-.07.226c-.391 1.891-.477 3.344-.223 4.395.148.629.425 1.14.84 1.508.44.39 1 .582 1.625.582 1.035 0 2.12-.473 3.28-1.364.477-.37.973-.816 1.489-1.336a1.2 1.2 0 0 0 .195.227c1.446 1.285 2.66 2.082 3.7 2.39.617.184 1.195.2 1.722.024.559-.187 1.004-.574 1.317-1.117.515-.894.652-2.074.46-3.527a14.941 14.941 0 0 0-.425-2.012 1.225 1.225 0 0 0 .238-.047c1.828-.61 3.125-1.258 3.91-2.004.465-.441.77-.937.883-1.48.113-.578 0-1.157-.313-1.7-.515-.894-1.464-1.597-2.816-2.156a14.576 14.576 0 0 0-1.906-.625.865.865 0 0 0 .059-.195z" />
|
||||
</svg>
|
||||
<p className="mt-2 font-medium">TanStack Start</p>
|
||||
</LinkedCard>
|
||||
<LinkedCard href="/docs/installation/laravel">
|
||||
<svg
|
||||
role="img"
|
||||
viewBox="0 0 62 65"
|
||||
fill="currentColor"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
className="h-10 w-10"
|
||||
>
|
||||
<path d="M61.8548 14.6253C61.8778 14.7102 61.8895 14.7978 61.8897 14.8858V28.5615C61.8898 28.737 61.8434 28.9095 61.7554 29.0614C61.6675 29.2132 61.5409 29.3392 61.3887 29.4265L49.9104 36.0351V49.1337C49.9104 49.4902 49.7209 49.8192 49.4118 49.9987L25.4519 63.7916C25.3971 63.8227 25.3372 63.8427 25.2774 63.8639C25.255 63.8714 25.2338 63.8851 25.2101 63.8913C25.0426 63.9354 24.8666 63.9354 24.6991 63.8913C24.6716 63.8838 24.6467 63.8689 24.6205 63.8589C24.5657 63.8389 24.5084 63.8215 24.456 63.7916L0.501061 49.9987C0.348882 49.9113 0.222437 49.7853 0.134469 49.6334C0.0465019 49.4816 0.000120578 49.3092 0 49.1337L0 8.10652C0 8.01678 0.0124642 7.92953 0.0348998 7.84477C0.0423783 7.8161 0.0598282 7.78993 0.0697995 7.76126C0.0884958 7.70891 0.105946 7.65531 0.133367 7.6067C0.152063 7.5743 0.179485 7.54812 0.20192 7.51821C0.230588 7.47832 0.256763 7.43719 0.290416 7.40229C0.319084 7.37362 0.356476 7.35243 0.388883 7.32751C0.425029 7.29759 0.457436 7.26518 0.498568 7.2415L12.4779 0.345059C12.6296 0.257786 12.8015 0.211853 12.9765 0.211853C13.1515 0.211853 13.3234 0.257786 13.475 0.345059L25.4531 7.2415H25.4556C25.4955 7.26643 25.5292 7.29759 25.5653 7.32626C25.5977 7.35119 25.6339 7.37362 25.6625 7.40104C25.6974 7.43719 25.7224 7.47832 25.7523 7.51821C25.7735 7.54812 25.8021 7.5743 25.8196 7.6067C25.8483 7.65656 25.8645 7.70891 25.8844 7.76126C25.8944 7.78993 25.9118 7.8161 25.9193 7.84602C25.9423 7.93096 25.954 8.01853 25.9542 8.10652V33.7317L35.9355 27.9844V14.8846C35.9355 14.7973 35.948 14.7088 35.9704 14.6253C35.9792 14.5954 35.9954 14.5692 36.0053 14.5405C36.0253 14.4882 36.0427 14.4346 36.0702 14.386C36.0888 14.3536 36.1163 14.3274 36.1375 14.2975C36.1674 14.2576 36.1923 14.2165 36.2272 14.1816C36.2559 14.1529 36.292 14.1317 36.3244 14.1068C36.3618 14.0769 36.3942 14.0445 36.4341 14.0208L48.4147 7.12434C48.5663 7.03694 48.7383 6.99094 48.9133 6.99094C49.0883 6.99094 49.2602 7.03694 49.4118 7.12434L61.3899 14.0208C61.4323 14.0457 61.4647 14.0769 61.5021 14.1055C61.5333 14.1305 61.5694 14.1529 61.5981 14.1803C61.633 14.2165 61.6579 14.2576 61.6878 14.2975C61.7103 14.3274 61.7377 14.3536 61.7551 14.386C61.7838 14.4346 61.8 14.4882 61.8199 14.5405C61.8312 14.5692 61.8474 14.5954 61.8548 14.6253ZM59.893 27.9844V16.6121L55.7013 19.0252L49.9104 22.3593V33.7317L59.8942 27.9844H59.893ZM47.9149 48.5566V37.1768L42.2187 40.4299L25.953 49.7133V61.2003L47.9149 48.5566ZM1.99677 9.83281V48.5566L23.9562 61.199V49.7145L12.4841 43.2219L12.4804 43.2194L12.4754 43.2169C12.4368 43.1945 12.4044 43.1621 12.3682 43.1347C12.3371 43.1097 12.3009 43.0898 12.2735 43.0624L12.271 43.0586C12.2386 43.0275 12.2162 42.9888 12.1887 42.9539C12.1638 42.9203 12.1339 42.8916 12.114 42.8567L12.1127 42.853C12.0903 42.8156 12.0766 42.7707 12.0604 42.7283C12.0442 42.6909 12.023 42.656 12.013 42.6161C12.0005 42.5688 11.998 42.5177 11.9931 42.4691C11.9881 42.4317 11.9781 42.3943 11.9781 42.3569V15.5801L6.18848 12.2446L1.99677 9.83281ZM12.9777 2.36177L2.99764 8.10652L12.9752 13.8513L22.9541 8.10527L12.9752 2.36177H12.9777ZM18.1678 38.2138L23.9574 34.8809V9.83281L19.7657 12.2459L13.9749 15.5801V40.6281L18.1678 38.2138ZM48.9133 9.14105L38.9344 14.8858L48.9133 20.6305L58.8909 14.8846L48.9133 9.14105ZM47.9149 22.3593L42.124 19.0252L37.9323 16.6121V27.9844L43.7219 31.3174L47.9149 33.7317V22.3593ZM24.9533 47.987L39.59 39.631L46.9065 35.4555L36.9352 29.7145L25.4544 36.3242L14.9907 42.3482L24.9533 47.987Z" />
|
||||
</svg>
|
||||
<p className="mt-2 font-medium">Laravel</p>
|
||||
</LinkedCard>
|
||||
<LinkedCard href="/docs/installation/react-router">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
className="h-10 w-10"
|
||||
fill="currentColor"
|
||||
>
|
||||
<path d="M12.118 5.466a2.306 2.306 0 0 0-.623.08c-.278.067-.702.332-.953.583-.41.423-.49.609-.662 1.469-.08.423.41 1.43.847 1.734.45.317 1.085.502 2.065.608 1.429.16 1.84.636 1.84 2.197 0 1.377-.385 1.747-1.96 1.906-1.707.172-2.58.834-2.765 2.117-.106.781.41 1.76 1.125 2.091 1.627.768 3.15-.198 3.467-2.196.211-1.284.622-1.642 1.998-1.747 1.588-.133 2.409-.675 2.713-1.787.278-1.02-.304-2.157-1.297-2.554-.264-.106-.873-.238-1.35-.291-1.495-.16-1.879-.424-2.038-1.39-.225-1.337-.317-1.562-.794-2.09a2.174 2.174 0 0 0-1.613-.73zm-4.785 4.36a2.145 2.145 0 0 0-.497.048c-1.469.318-2.17 2.051-1.35 3.295 1.178 1.774 3.944.953 3.97-1.177.012-1.193-.98-2.143-2.123-2.166zM2.089 14.19a2.22 2.22 0 0 0-.427.052c-2.158.476-2.237 3.626-.106 4.182.53.145.582.145 1.111.013 1.191-.318 1.866-1.456 1.549-2.607-.278-1.02-1.144-1.664-2.127-1.64zm19.824.008c-.233.002-.477.058-.784.162-1.39.477-1.866 2.092-.98 3.336.557.794 1.96 1.058 2.82.516 1.416-.874 1.363-3.057-.093-3.746-.38-.186-.663-.271-.963-.268z" />
|
||||
</svg>
|
||||
<p className="mt-2 font-medium">React Router</p>
|
||||
</LinkedCard>
|
||||
<LinkedCard href="/docs/installation/astro">
|
||||
<svg
|
||||
role="img"
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
className="h-10 w-10"
|
||||
fill="currentColor"
|
||||
>
|
||||
<title>Astro</title>
|
||||
<path
|
||||
d="M16.074 16.86C15.354 17.476 13.917 17.895 12.262 17.895C10.23 17.895 8.527 17.263 8.075 16.412C7.914 16.9 7.877 17.458 7.877 17.814C7.877 17.814 7.771 19.564 8.988 20.782C8.988 20.15 9.501 19.637 10.133 19.637C11.216 19.637 11.215 20.582 11.214 21.349V21.418C11.214 22.582 11.925 23.579 12.937 24C12.7812 23.6794 12.7005 23.3275 12.701 22.971C12.701 21.861 13.353 21.448 14.111 20.968C14.713 20.585 15.383 20.161 15.844 19.308C16.0926 18.8493 16.2225 18.3357 16.222 17.814C16.2221 17.4903 16.1722 17.1685 16.074 16.86ZM15.551 0.6C15.747 0.844 15.847 1.172 16.047 1.829L20.415 16.176C18.7743 15.3246 17.0134 14.7284 15.193 14.408L12.35 4.8C12.3273 4.72337 12.2803 4.65616 12.2162 4.60844C12.152 4.56072 12.0742 4.53505 11.9943 4.53528C11.9143 4.5355 11.8366 4.56161 11.7727 4.60969C11.7089 4.65777 11.6623 4.72524 11.64 4.802L8.83 14.405C7.00149 14.724 5.23264 15.3213 3.585 16.176L7.974 1.827C8.174 1.171 8.274 0.843 8.471 0.6C8.64406 0.385433 8.86922 0.218799 9.125 0.116C9.415 0 9.757 0 10.443 0H13.578C14.264 0 14.608 0 14.898 0.117C15.1529 0.219851 15.3783 0.386105 15.551 0.6Z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
</svg>
|
||||
<p className="mt-2 font-medium">Astro</p>
|
||||
</LinkedCard>
|
||||
<LinkedCard href="/docs/installation/manual">
|
||||
<svg
|
||||
role="img"
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
className="h-10 w-10"
|
||||
fill="currentColor"
|
||||
>
|
||||
<title>React</title>
|
||||
<path d="M14.23 12.004a2.236 2.236 0 0 1-2.235 2.236 2.236 2.236 0 0 1-2.236-2.236 2.236 2.236 0 0 1 2.235-2.236 2.236 2.236 0 0 1 2.236 2.236zm2.648-10.69c-1.346 0-3.107.96-4.888 2.622-1.78-1.653-3.542-2.602-4.887-2.602-.41 0-.783.093-1.106.278-1.375.793-1.683 3.264-.973 6.365C1.98 8.917 0 10.42 0 12.004c0 1.59 1.99 3.097 5.043 4.03-.704 3.113-.39 5.588.988 6.38.32.187.69.275 1.102.275 1.345 0 3.107-.96 4.888-2.624 1.78 1.654 3.542 2.603 4.887 2.603.41 0 .783-.09 1.106-.275 1.374-.792 1.683-3.263.973-6.365C22.02 15.096 24 13.59 24 12.004c0-1.59-1.99-3.097-5.043-4.032.704-3.11.39-5.587-.988-6.38-.318-.184-.688-.277-1.092-.278zm-.005 1.09v.006c.225 0 .406.044.558.127.666.382.955 1.835.73 3.704-.054.46-.142.945-.25 1.44-.96-.236-2.006-.417-3.107-.534-.66-.905-1.345-1.727-2.035-2.447 1.592-1.48 3.087-2.292 4.105-2.295zm-9.77.02c1.012 0 2.514.808 4.11 2.28-.686.72-1.37 1.537-2.02 2.442-1.107.117-2.154.298-3.113.538-.112-.49-.195-.964-.254-1.42-.23-1.868.054-3.32.714-3.707.19-.09.4-.127.563-.132zm4.882 3.05c.455.468.91.992 1.36 1.564-.44-.02-.89-.034-1.345-.034-.46 0-.915.01-1.36.034.44-.572.895-1.096 1.345-1.565zM12 8.1c.74 0 1.477.034 2.202.093.406.582.802 1.203 1.183 1.86.372.64.71 1.29 1.018 1.946-.308.655-.646 1.31-1.013 1.95-.38.66-.773 1.288-1.18 1.87-.728.063-1.466.098-2.21.098-.74 0-1.477-.035-2.202-.093-.406-.582-.802-1.204-1.183-1.86-.372-.64-.71-1.29-1.018-1.946.303-.657.646-1.313 1.013-1.954.38-.66.773-1.286 1.18-1.868.728-.064 1.466-.098 2.21-.098zm-3.635.254c-.24.377-.48.763-.704 1.16-.225.39-.435.782-.635 1.174-.265-.656-.49-1.31-.676-1.947.64-.15 1.315-.283 2.015-.386zm7.26 0c.695.103 1.365.23 2.006.387-.18.632-.405 1.282-.66 1.933-.2-.39-.41-.783-.64-1.174-.225-.392-.465-.774-.705-1.146zm3.063.675c.484.15.944.317 1.375.498 1.732.74 2.852 1.708 2.852 2.476-.005.768-1.125 1.74-2.857 2.475-.42.18-.88.342-1.355.493-.28-.958-.646-1.956-1.1-2.98.45-1.017.81-2.01 1.085-2.964zm-13.395.004c.278.96.645 1.957 1.1 2.98-.45 1.017-.812 2.01-1.086 2.964-.484-.15-.944-.318-1.37-.5-1.732-.737-2.852-1.706-2.852-2.474 0-.768 1.12-1.742 2.852-2.476.42-.18.88-.342 1.356-.494zm11.678 4.28c.265.657.49 1.312.676 1.948-.64.157-1.316.29-2.016.39.24-.375.48-.762.705-1.158.225-.39.435-.788.636-1.18zm-9.945.02c.2.392.41.783.64 1.175.23.39.465.772.705 1.143-.695-.102-1.365-.23-2.006-.386.18-.63.406-1.282.66-1.933zM17.92 16.32c.112.493.2.968.254 1.423.23 1.868-.054 3.32-.714 3.708-.147.09-.338.128-.563.128-1.012 0-2.514-.807-4.11-2.28.686-.72 1.37-1.536 2.02-2.44 1.107-.118 2.154-.3 3.113-.54zm-11.83.01c.96.234 2.006.415 3.107.532.66.905 1.345 1.727 2.035 2.446-1.595 1.483-3.092 2.295-4.11 2.295-.22-.005-.406-.05-.553-.132-.666-.38-.955-1.834-.73-3.703.054-.46.142-.944.25-1.438zm4.56.64c.44.02.89.034 1.345.034.46 0 .915-.01 1.36-.034-.44.572-.895 1.095-1.345 1.565-.455-.47-.91-.993-1.36-1.565z" />
|
||||
</svg>
|
||||
<p className="mt-2 font-medium">Manual</p>
|
||||
</LinkedCard>
|
||||
</div>
|
||||
150
apps/v4/content/docs/installation/laravel.mdx
Normal file
150
apps/v4/content/docs/installation/laravel.mdx
Normal file
@@ -0,0 +1,150 @@
|
||||
---
|
||||
title: Laravel
|
||||
description: Install and configure shadcn/ui for Laravel.
|
||||
---
|
||||
|
||||
The shadcn CLI does not scaffold a new Laravel app. Start by creating a Laravel app with the React starter kit, then choose how you want to configure shadcn/ui.
|
||||
|
||||
<Steps>
|
||||
|
||||
### Create Project
|
||||
|
||||
Create a new Laravel app using the Laravel installer:
|
||||
|
||||
```bash
|
||||
laravel new my-app
|
||||
```
|
||||
|
||||
If you already have a Laravel app with React and Inertia configured, skip this step.
|
||||
|
||||
Choose the **React** starter kit when prompted. For more information, see the official [Laravel frontend documentation](https://laravel.com/docs/12.x/frontend).
|
||||
|
||||
Then move into your project directory:
|
||||
|
||||
```bash
|
||||
cd my-app
|
||||
```
|
||||
|
||||
</Steps>
|
||||
|
||||
<div className="mt-10 grid gap-4 sm:grid-cols-2 sm:gap-6">
|
||||
<LinkedCard
|
||||
href="#configure-with-create"
|
||||
className="items-start gap-1 p-6 text-sm md:p-6"
|
||||
>
|
||||
<div className="font-medium">Use shadcn/create</div>
|
||||
<div className="leading-relaxed text-muted-foreground">
|
||||
Build your preset visually and generate a Laravel init command.
|
||||
</div>
|
||||
</LinkedCard>
|
||||
<LinkedCard
|
||||
href="#configure-with-cli"
|
||||
className="items-start gap-1 p-6 text-sm md:p-6"
|
||||
>
|
||||
<div className="font-medium">Use the CLI</div>
|
||||
<div className="leading-relaxed text-muted-foreground">
|
||||
Configure shadcn/ui in your Laravel app directly from the terminal.
|
||||
</div>
|
||||
</LinkedCard>
|
||||
</div>
|
||||
|
||||
<div id="configure-with-create" className="scroll-mt-24" />
|
||||
## Use shadcn/create
|
||||
|
||||
<Steps>
|
||||
|
||||
### Build Your Preset
|
||||
|
||||
Open [shadcn/create](/create?template=laravel) and build your preset visually. Choose your style, colors, fonts, icons, and more.
|
||||
|
||||
<Button asChild size="sm">
|
||||
<Link
|
||||
href="/create?template=laravel"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="mt-6 no-underline!"
|
||||
>
|
||||
Open shadcn/create
|
||||
</Link>
|
||||
</Button>
|
||||
|
||||
### Run the Command
|
||||
|
||||
Click `Create Project`, choose your package manager, and copy the generated command.
|
||||
|
||||
The generated command will look similar to this:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest init --preset [CODE] --template laravel
|
||||
```
|
||||
|
||||
Run the command from the root of your Laravel app.
|
||||
|
||||
When asked to overwrite `components.json` and components, choose `Yes`.
|
||||
|
||||
### Add Components
|
||||
|
||||
Add the `Switch` component to your project:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add switch
|
||||
```
|
||||
|
||||
The command above will add the `Switch` component to `resources/js/components/ui/switch.tsx`. You can then import it like this:
|
||||
|
||||
```tsx title="resources/js/pages/index.tsx" showLineNumbers {1,6}
|
||||
import { Switch } from "@/components/ui/switch"
|
||||
|
||||
const MyPage = () => {
|
||||
return (
|
||||
<div>
|
||||
<Switch />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default MyPage
|
||||
```
|
||||
|
||||
</Steps>
|
||||
|
||||
<div id="configure-with-cli" className="scroll-mt-24" />
|
||||
## Use the CLI
|
||||
|
||||
<Steps>
|
||||
|
||||
### Run the CLI
|
||||
|
||||
Run the `shadcn` init command from the root of your Laravel app:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest init
|
||||
```
|
||||
|
||||
When asked to overwrite `components.json` and components, choose `Yes`.
|
||||
|
||||
### Add Components
|
||||
|
||||
Add the `Switch` component to your project:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add switch
|
||||
```
|
||||
|
||||
The command above will add the `Switch` component to `resources/js/components/ui/switch.tsx`. You can then import it like this:
|
||||
|
||||
```tsx title="resources/js/pages/index.tsx" showLineNumbers {1,6}
|
||||
import { Switch } from "@/components/ui/switch"
|
||||
|
||||
const MyPage = () => {
|
||||
return (
|
||||
<div>
|
||||
<Switch />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default MyPage
|
||||
```
|
||||
|
||||
</Steps>
|
||||
255
apps/v4/content/docs/installation/manual.mdx
Normal file
255
apps/v4/content/docs/installation/manual.mdx
Normal file
@@ -0,0 +1,255 @@
|
||||
---
|
||||
title: Manual Installation
|
||||
description: Add dependencies to your project manually.
|
||||
---
|
||||
|
||||
<Steps>
|
||||
|
||||
### Add Tailwind CSS
|
||||
|
||||
Components are styled using Tailwind CSS. You need to install Tailwind CSS in your project.
|
||||
|
||||
[Follow the Tailwind CSS installation instructions to get started.](https://tailwindcss.com/docs/installation)
|
||||
|
||||
### Add dependencies
|
||||
|
||||
Add the following dependencies to your project:
|
||||
|
||||
```bash
|
||||
npm install shadcn class-variance-authority cn lucide-react tw-animate-css
|
||||
```
|
||||
|
||||
### Configure import aliases
|
||||
|
||||
Choose one of the following alias setups.
|
||||
|
||||
#### Option A: `tsconfig.json` paths
|
||||
|
||||
```json {3-6} title="tsconfig.json" showLineNumbers
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["./*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Option B: `package.json#imports`
|
||||
|
||||
```json title="package.json" showLineNumbers
|
||||
{
|
||||
"imports": {
|
||||
"#components/*": "./src/components/*.tsx",
|
||||
"#lib/*": "./src/lib/*.ts",
|
||||
"#hooks/*": "./src/hooks/*.ts"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```json title="tsconfig.json" showLineNumbers
|
||||
{
|
||||
"compilerOptions": {
|
||||
"moduleResolution": "bundler",
|
||||
"resolvePackageJsonImports": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The `@` alias is a preference. You can use other aliases if you want. If you
|
||||
use `package.json#imports`, keep the matching alias roots in `components.json`.
|
||||
See the <Link href="/docs/package-imports">package imports guide</Link> for
|
||||
framework-specific setup.
|
||||
|
||||
### Configure styles
|
||||
|
||||
Add the following to your styles/globals.css file. You can learn more about using CSS variables for theming in the [theming section](/docs/theming).
|
||||
|
||||
<CodeCollapsibleWrapper>
|
||||
|
||||
```css showLineNumbers title="src/styles/globals.css"
|
||||
@import "tailwindcss";
|
||||
@import "tw-animate-css";
|
||||
@import "shadcn/tailwind.css";
|
||||
|
||||
@custom-variant dark (&:is(.dark *));
|
||||
|
||||
@theme inline {
|
||||
--color-background: var(--background);
|
||||
--color-foreground: var(--foreground);
|
||||
--color-card: var(--card);
|
||||
--color-card-foreground: var(--card-foreground);
|
||||
--color-popover: var(--popover);
|
||||
--color-popover-foreground: var(--popover-foreground);
|
||||
--color-primary: var(--primary);
|
||||
--color-primary-foreground: var(--primary-foreground);
|
||||
--color-secondary: var(--secondary);
|
||||
--color-secondary-foreground: var(--secondary-foreground);
|
||||
--color-muted: var(--muted);
|
||||
--color-muted-foreground: var(--muted-foreground);
|
||||
--color-accent: var(--accent);
|
||||
--color-accent-foreground: var(--accent-foreground);
|
||||
--color-destructive: var(--destructive);
|
||||
--color-destructive-foreground: var(--destructive-foreground);
|
||||
--color-border: var(--border);
|
||||
--color-input: var(--input);
|
||||
--color-ring: var(--ring);
|
||||
--color-chart-1: var(--chart-1);
|
||||
--color-chart-2: var(--chart-2);
|
||||
--color-chart-3: var(--chart-3);
|
||||
--color-chart-4: var(--chart-4);
|
||||
--color-chart-5: var(--chart-5);
|
||||
--radius-sm: calc(var(--radius) * 0.6);
|
||||
--radius-md: calc(var(--radius) * 0.8);
|
||||
--radius-lg: var(--radius);
|
||||
--radius-xl: calc(var(--radius) * 1.4);
|
||||
--radius-2xl: calc(var(--radius) * 1.8);
|
||||
--radius-3xl: calc(var(--radius) * 2.2);
|
||||
--radius-4xl: calc(var(--radius) * 2.6);
|
||||
--color-sidebar: var(--sidebar);
|
||||
--color-sidebar-foreground: var(--sidebar-foreground);
|
||||
--color-sidebar-primary: var(--sidebar-primary);
|
||||
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
||||
--color-sidebar-accent: var(--sidebar-accent);
|
||||
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
||||
--color-sidebar-border: var(--sidebar-border);
|
||||
--color-sidebar-ring: var(--sidebar-ring);
|
||||
}
|
||||
|
||||
:root {
|
||||
--radius: 0.625rem;
|
||||
--background: oklch(1 0 0);
|
||||
--foreground: oklch(0.145 0 0);
|
||||
--card: oklch(1 0 0);
|
||||
--card-foreground: oklch(0.145 0 0);
|
||||
--popover: oklch(1 0 0);
|
||||
--popover-foreground: oklch(0.145 0 0);
|
||||
--primary: oklch(0.205 0 0);
|
||||
--primary-foreground: oklch(0.985 0 0);
|
||||
--secondary: oklch(0.97 0 0);
|
||||
--secondary-foreground: oklch(0.205 0 0);
|
||||
--muted: oklch(0.97 0 0);
|
||||
--muted-foreground: oklch(0.556 0 0);
|
||||
--accent: oklch(0.97 0 0);
|
||||
--accent-foreground: oklch(0.205 0 0);
|
||||
--destructive: oklch(0.577 0.245 27.325);
|
||||
--border: oklch(0.922 0 0);
|
||||
--input: oklch(0.922 0 0);
|
||||
--ring: oklch(0.708 0 0);
|
||||
--chart-1: oklch(0.646 0.222 41.116);
|
||||
--chart-2: oklch(0.6 0.118 184.704);
|
||||
--chart-3: oklch(0.398 0.07 227.392);
|
||||
--chart-4: oklch(0.828 0.189 84.429);
|
||||
--chart-5: oklch(0.769 0.188 70.08);
|
||||
--sidebar: oklch(0.985 0 0);
|
||||
--sidebar-foreground: oklch(0.145 0 0);
|
||||
--sidebar-primary: oklch(0.205 0 0);
|
||||
--sidebar-primary-foreground: oklch(0.985 0 0);
|
||||
--sidebar-accent: oklch(0.97 0 0);
|
||||
--sidebar-accent-foreground: oklch(0.205 0 0);
|
||||
--sidebar-border: oklch(0.922 0 0);
|
||||
--sidebar-ring: oklch(0.708 0 0);
|
||||
}
|
||||
|
||||
.dark {
|
||||
--background: oklch(0.145 0 0);
|
||||
--foreground: oklch(0.985 0 0);
|
||||
--card: oklch(0.205 0 0);
|
||||
--card-foreground: oklch(0.985 0 0);
|
||||
--popover: oklch(0.205 0 0);
|
||||
--popover-foreground: oklch(0.985 0 0);
|
||||
--primary: oklch(0.922 0 0);
|
||||
--primary-foreground: oklch(0.205 0 0);
|
||||
--secondary: oklch(0.269 0 0);
|
||||
--secondary-foreground: oklch(0.985 0 0);
|
||||
--muted: oklch(0.269 0 0);
|
||||
--muted-foreground: oklch(0.708 0 0);
|
||||
--accent: oklch(0.269 0 0);
|
||||
--accent-foreground: oklch(0.985 0 0);
|
||||
--destructive: oklch(0.704 0.191 22.216);
|
||||
--border: oklch(1 0 0 / 10%);
|
||||
--input: oklch(1 0 0 / 15%);
|
||||
--ring: oklch(0.556 0 0);
|
||||
--chart-1: oklch(0.488 0.243 264.376);
|
||||
--chart-2: oklch(0.696 0.17 162.48);
|
||||
--chart-3: oklch(0.769 0.188 70.08);
|
||||
--chart-4: oklch(0.627 0.265 303.9);
|
||||
--chart-5: oklch(0.645 0.246 16.439);
|
||||
--sidebar: oklch(0.205 0 0);
|
||||
--sidebar-foreground: oklch(0.985 0 0);
|
||||
--sidebar-primary: oklch(0.488 0.243 264.376);
|
||||
--sidebar-primary-foreground: oklch(0.985 0 0);
|
||||
--sidebar-accent: oklch(0.269 0 0);
|
||||
--sidebar-accent-foreground: oklch(0.985 0 0);
|
||||
--sidebar-border: oklch(1 0 0 / 10%);
|
||||
--sidebar-ring: oklch(0.556 0 0);
|
||||
}
|
||||
|
||||
@layer base {
|
||||
* {
|
||||
@apply border-border outline-ring/50;
|
||||
}
|
||||
body {
|
||||
@apply bg-background text-foreground;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</CodeCollapsibleWrapper>
|
||||
|
||||
### Add a cn helper
|
||||
|
||||
Components import `cn` directly from the `cn` package. Re-export it from `lib/utils.ts` so your own code has a single place to import helpers from.
|
||||
|
||||
```ts showLineNumbers title="lib/utils.ts"
|
||||
export { cn } from "cn"
|
||||
```
|
||||
|
||||
### Create a `components.json` file
|
||||
|
||||
Create a `components.json` file in the root of your project.
|
||||
|
||||
```json title="components.json" showLineNumbers
|
||||
{
|
||||
"$schema": "https://ui.shadcn.com/schema.json",
|
||||
"style": "base-nova",
|
||||
"rsc": false,
|
||||
"tsx": true,
|
||||
"tailwind": {
|
||||
"config": "",
|
||||
"css": "src/styles/globals.css",
|
||||
"baseColor": "neutral",
|
||||
"cssVariables": true,
|
||||
"prefix": ""
|
||||
},
|
||||
"aliases": {
|
||||
"components": "@/components",
|
||||
"utils": "@/lib/utils",
|
||||
"ui": "@/components/ui",
|
||||
"lib": "@/lib",
|
||||
"hooks": "@/hooks"
|
||||
},
|
||||
"iconLibrary": "lucide"
|
||||
}
|
||||
```
|
||||
|
||||
If you're using `package.json#imports`, use the corresponding `#...` aliases instead:
|
||||
|
||||
```json title="components.json" showLineNumbers
|
||||
{
|
||||
"aliases": {
|
||||
"components": "#components",
|
||||
"utils": "#lib/utils",
|
||||
"ui": "#components/ui",
|
||||
"lib": "#lib",
|
||||
"hooks": "#hooks"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### That's it
|
||||
|
||||
You can now start adding components to your project.
|
||||
|
||||
</Steps>
|
||||
13
apps/v4/content/docs/installation/meta.json
Normal file
13
apps/v4/content/docs/installation/meta.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"pages": [
|
||||
"next",
|
||||
"vite",
|
||||
"laravel",
|
||||
"react-router",
|
||||
"remix",
|
||||
"astro",
|
||||
"tanstack",
|
||||
"tanstack-router",
|
||||
"manual"
|
||||
]
|
||||
}
|
||||
256
apps/v4/content/docs/installation/next.mdx
Normal file
256
apps/v4/content/docs/installation/next.mdx
Normal file
@@ -0,0 +1,256 @@
|
||||
---
|
||||
title: Next.js
|
||||
description: Install and configure shadcn/ui for Next.js.
|
||||
---
|
||||
|
||||
Choose the setup that matches your starting point.
|
||||
|
||||
<div className="mt-6 grid gap-4 sm:grid-cols-3 sm:gap-6">
|
||||
<LinkedCard
|
||||
href="#scaffold-with-create"
|
||||
className="items-start gap-1 p-6 text-sm md:p-6"
|
||||
>
|
||||
<div className="font-medium">Use shadcn/create</div>
|
||||
<div className="leading-relaxed text-muted-foreground">
|
||||
Build your preset and generate a Next.js project command.
|
||||
</div>
|
||||
</LinkedCard>
|
||||
<LinkedCard
|
||||
href="#scaffold-with-cli"
|
||||
className="items-start gap-1 p-6 text-sm md:p-6"
|
||||
>
|
||||
<div className="font-medium">Use the CLI</div>
|
||||
<div className="leading-relaxed text-muted-foreground">
|
||||
Scaffold a new Next.js project directly from the terminal.
|
||||
</div>
|
||||
</LinkedCard>
|
||||
<LinkedCard
|
||||
href="#existing-next-project"
|
||||
className="items-start gap-1 p-6 text-sm md:p-6"
|
||||
>
|
||||
<div className="font-medium">Existing Project</div>
|
||||
<div className="leading-relaxed text-muted-foreground">
|
||||
Configure shadcn/ui manually in an existing Next.js project.
|
||||
</div>
|
||||
</LinkedCard>
|
||||
</div>
|
||||
|
||||
<div id="scaffold-with-create" className="scroll-mt-24" />
|
||||
## Use shadcn/create
|
||||
|
||||
<Steps>
|
||||
|
||||
### Build Your Preset
|
||||
|
||||
Open [shadcn/create](/create?template=next) and build your preset visually. Choose your style, colors, fonts, icons, and more.
|
||||
|
||||
<Button asChild size="sm">
|
||||
<Link
|
||||
href="/create?template=next"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="mt-6 no-underline!"
|
||||
>
|
||||
Open shadcn/create
|
||||
</Link>
|
||||
</Button>
|
||||
|
||||
### Create Project
|
||||
|
||||
Click `Create Project`, choose your package manager, and copy the generated command.
|
||||
|
||||
The generated command will look similar to this:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest init --preset [CODE] --template next
|
||||
```
|
||||
|
||||
The exact command will include your selected options such as `--base`, `--monorepo`, or `--rtl`.
|
||||
|
||||
### Add Components
|
||||
|
||||
Add the `Card` component to your project:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add card
|
||||
```
|
||||
|
||||
If you created a monorepo, run the command from `apps/web` or specify the workspace from the repo root:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add card -c apps/web
|
||||
```
|
||||
|
||||
The command above will add the `Card` component to your project. You can then import it like this:
|
||||
|
||||
```tsx showLineNumbers title="app/page.tsx"
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card"
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<Card className="max-w-sm">
|
||||
<CardHeader>
|
||||
<CardTitle>Project Overview</CardTitle>
|
||||
<CardDescription>
|
||||
Track progress and recent activity for your Next.js app.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
Your design system is ready. Start building your next component.
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
If you created a monorepo, update `apps/web/app/page.tsx` and import from `@workspace/ui/components/card` instead.
|
||||
|
||||
</Steps>
|
||||
|
||||
<div id="scaffold-with-cli" className="scroll-mt-24" />
|
||||
## Use the CLI
|
||||
|
||||
<Steps>
|
||||
|
||||
### Create Project
|
||||
|
||||
Run the `init` command to scaffold a new Next.js project. Follow the prompts to configure your project: base, preset, monorepo, and more.
|
||||
|
||||
```bash
|
||||
npx shadcn@latest init -t next
|
||||
```
|
||||
|
||||
**For a monorepo project, use `--monorepo` flag:**
|
||||
|
||||
```bash
|
||||
npx shadcn@latest init -t next --monorepo
|
||||
```
|
||||
|
||||
### Add Components
|
||||
|
||||
Add the `Card` component to your project:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add card
|
||||
```
|
||||
|
||||
If you created a monorepo, run the command from `apps/web` or specify the workspace from the repo root:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add card -c apps/web
|
||||
```
|
||||
|
||||
The command above will add the `Card` component to your project. You can then import it like this:
|
||||
|
||||
```tsx showLineNumbers title="app/page.tsx"
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card"
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<Card className="max-w-sm">
|
||||
<CardHeader>
|
||||
<CardTitle>Project Overview</CardTitle>
|
||||
<CardDescription>
|
||||
Track progress and recent activity for your Next.js app.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
Your design system is ready. Start building your next component.
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
If you created a monorepo, update `apps/web/app/page.tsx` and import from `@workspace/ui/components/card` instead.
|
||||
|
||||
</Steps>
|
||||
|
||||
<div id="existing-next-project" className="scroll-mt-24" />
|
||||
## Existing Project
|
||||
|
||||
<Steps>
|
||||
|
||||
### Create Project
|
||||
|
||||
If you need a new Next.js project, create one with `create-next-app`. Otherwise, skip this step.
|
||||
|
||||
```bash
|
||||
npx create-next-app@latest
|
||||
```
|
||||
|
||||
Choose the recommended defaults so Tailwind CSS, the App Router, and the default `@/*` import alias are configured for you.
|
||||
|
||||
If you prefer a `src/` directory, use `--src-dir` or choose `Yes` when prompted:
|
||||
|
||||
```bash
|
||||
npx create-next-app@latest --src-dir
|
||||
```
|
||||
|
||||
With `--src-dir`, Next.js places your app in `src/app` and configures the `@/*` alias to point to `./src/*`.
|
||||
|
||||
### Configure Tailwind CSS and Import Aliases
|
||||
|
||||
If you created your project with the recommended `create-next-app` defaults, you can skip this step.
|
||||
|
||||
If you're adding shadcn/ui to an older or custom Next.js app, make sure Tailwind CSS is installed first. You can follow the official [Next.js installation guide](https://nextjs.org/docs/app/getting-started).
|
||||
|
||||
Then make sure your `tsconfig.json` includes the `@/*` import alias:
|
||||
|
||||
```json title="tsconfig.json" showLineNumbers
|
||||
{
|
||||
"compilerOptions": {
|
||||
"paths": {
|
||||
"@/*": ["./*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If you used `--src-dir`, point the alias to `./src/*` instead.
|
||||
|
||||
### Run the CLI
|
||||
|
||||
Run the `shadcn` init command to set up shadcn/ui in your project.
|
||||
|
||||
```bash
|
||||
npx shadcn@latest init
|
||||
```
|
||||
|
||||
### Add Components
|
||||
|
||||
You can now start adding components to your project.
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add button
|
||||
```
|
||||
|
||||
The command above will add the `Button` component to your project. You can then import it like this:
|
||||
|
||||
```tsx showLineNumbers title="app/page.tsx"
|
||||
import { Button } from "@/components/ui/button"
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<div className="flex min-h-svh items-center justify-center">
|
||||
<Button>Click me</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
If you used `--src-dir`, add the component to `src/app/page.tsx` instead.
|
||||
|
||||
</Steps>
|
||||
226
apps/v4/content/docs/installation/react-router.mdx
Normal file
226
apps/v4/content/docs/installation/react-router.mdx
Normal file
@@ -0,0 +1,226 @@
|
||||
---
|
||||
title: React Router
|
||||
description: Install and configure shadcn/ui for React Router.
|
||||
---
|
||||
|
||||
Choose the setup that matches your starting point.
|
||||
|
||||
<div className="mt-6 grid gap-4 sm:grid-cols-3 sm:gap-6">
|
||||
<LinkedCard
|
||||
href="#scaffold-with-create"
|
||||
className="items-start gap-1 p-6 text-sm md:p-6"
|
||||
>
|
||||
<div className="font-medium">Use shadcn/create</div>
|
||||
<div className="leading-relaxed text-muted-foreground">
|
||||
Build your preset and generate a React Router project.
|
||||
</div>
|
||||
</LinkedCard>
|
||||
<LinkedCard
|
||||
href="#scaffold-with-cli"
|
||||
className="items-start gap-1 p-6 text-sm md:p-6"
|
||||
>
|
||||
<div className="font-medium">Use the CLI</div>
|
||||
<div className="leading-relaxed text-muted-foreground">
|
||||
Scaffold a new React Router project directly from the terminal.
|
||||
</div>
|
||||
</LinkedCard>
|
||||
<LinkedCard
|
||||
href="#existing-react-router-project"
|
||||
className="items-start gap-1 p-6 text-sm md:p-6"
|
||||
>
|
||||
<div className="font-medium">Existing Project</div>
|
||||
<div className="leading-relaxed text-muted-foreground">
|
||||
Configure shadcn/ui manually in an existing React Router project.
|
||||
</div>
|
||||
</LinkedCard>
|
||||
</div>
|
||||
|
||||
<div id="scaffold-with-create" className="scroll-mt-24" />
|
||||
## Use shadcn/create
|
||||
|
||||
<Steps>
|
||||
|
||||
### Build Your Preset
|
||||
|
||||
Open [shadcn/create](/create?template=react-router) and build your preset visually. Choose your style, colors, fonts, icons, and more.
|
||||
|
||||
<Button asChild size="sm">
|
||||
<Link
|
||||
href="/create?template=react-router"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="mt-6 no-underline!"
|
||||
>
|
||||
Open shadcn/create
|
||||
</Link>
|
||||
</Button>
|
||||
|
||||
### Create Project
|
||||
|
||||
Click `Create Project`, choose your package manager, and copy the generated command.
|
||||
|
||||
The generated command will look similar to this:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest init --preset [CODE] --template react-router
|
||||
```
|
||||
|
||||
The exact command will include your selected options such as `--base`, `--monorepo`, or `--rtl`.
|
||||
|
||||
### Add Components
|
||||
|
||||
Add the `Card` component to your project:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add card
|
||||
```
|
||||
|
||||
If you created a monorepo, run the command from `apps/web` or specify the workspace from the repo root:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add card -c apps/web
|
||||
```
|
||||
|
||||
The command above will add the `Card` component to your project. You can then import it like this:
|
||||
|
||||
```tsx showLineNumbers title="app/routes/home.tsx"
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "~/components/ui/card"
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<Card className="max-w-sm">
|
||||
<CardHeader>
|
||||
<CardTitle>Project Overview</CardTitle>
|
||||
<CardDescription>
|
||||
Track progress and recent activity for your React Router app.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
Your design system is ready. Start building your next component.
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
If you created a monorepo, update `apps/web/app/routes/home.tsx` and import from `@workspace/ui/components/card` instead.
|
||||
|
||||
</Steps>
|
||||
|
||||
<div id="scaffold-with-cli" className="scroll-mt-24" />
|
||||
## Use the CLI
|
||||
|
||||
<Steps>
|
||||
|
||||
### Create Project
|
||||
|
||||
Run the `init` command to scaffold a new React Router project. Follow the prompts to configure your project: base, preset, monorepo, and more.
|
||||
|
||||
```bash
|
||||
npx shadcn@latest init -t react-router
|
||||
```
|
||||
|
||||
**For a monorepo project, use `--monorepo` flag:**
|
||||
|
||||
```bash
|
||||
npx shadcn@latest init -t react-router --monorepo
|
||||
```
|
||||
|
||||
### Add Components
|
||||
|
||||
Add the `Card` component to your project:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add card
|
||||
```
|
||||
|
||||
If you created a monorepo, run the command from `apps/web` or specify the workspace from the repo root:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add card -c apps/web
|
||||
```
|
||||
|
||||
The command above will add the `Card` component to your project. You can then import it like this:
|
||||
|
||||
```tsx showLineNumbers title="app/routes/home.tsx"
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "~/components/ui/card"
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<Card className="max-w-sm">
|
||||
<CardHeader>
|
||||
<CardTitle>Project Overview</CardTitle>
|
||||
<CardDescription>
|
||||
Track progress and recent activity for your React Router app.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
Your design system is ready. Start building your next component.
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
If you created a monorepo, update `apps/web/app/routes/home.tsx` and import from `@workspace/ui/components/card` instead.
|
||||
|
||||
</Steps>
|
||||
|
||||
<div id="existing-react-router-project" className="scroll-mt-24" />
|
||||
## Existing Project
|
||||
|
||||
<Steps>
|
||||
|
||||
### Create Project
|
||||
|
||||
If you need a new React Router project, create one first. Otherwise, skip this step.
|
||||
|
||||
```bash
|
||||
npm create react-router@latest
|
||||
```
|
||||
|
||||
`create-react-router` already configures Tailwind CSS and the default `~/*` import alias for you. If you're adding shadcn/ui to an older or custom React Router app, make sure both are configured before continuing.
|
||||
|
||||
### Run the CLI
|
||||
|
||||
Run the `shadcn` init command to set up shadcn/ui in your project.
|
||||
|
||||
```bash
|
||||
npx shadcn@latest init
|
||||
```
|
||||
|
||||
### Add Components
|
||||
|
||||
You can now start adding components to your project.
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add button
|
||||
```
|
||||
|
||||
The command above will add the `Button` component to your project. You can then import it like this:
|
||||
|
||||
```tsx showLineNumbers title="app/routes/home.tsx"
|
||||
import { Button } from "~/components/ui/button"
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<div className="flex min-h-svh flex-col items-center justify-center">
|
||||
<Button>Click me</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
</Steps>
|
||||
52
apps/v4/content/docs/installation/remix.mdx
Normal file
52
apps/v4/content/docs/installation/remix.mdx
Normal file
@@ -0,0 +1,52 @@
|
||||
---
|
||||
title: Remix
|
||||
description: Install and configure shadcn/ui for Remix.
|
||||
---
|
||||
|
||||
<Callout>
|
||||
|
||||
**Note:** This guide is for Remix. For React Router, see the [React Router](/docs/installation/react-router) guide.
|
||||
|
||||
</Callout>
|
||||
|
||||
<Steps>
|
||||
|
||||
### Create project
|
||||
|
||||
Start by creating a new Remix project using `create-remix`:
|
||||
|
||||
```bash
|
||||
npx create-remix@latest my-app
|
||||
```
|
||||
|
||||
### Run the CLI
|
||||
|
||||
Run the `shadcn` init command to set up your project:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest init
|
||||
```
|
||||
|
||||
### That's it
|
||||
|
||||
You can now start adding components to your project.
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add button
|
||||
```
|
||||
|
||||
The command above will add the `Button` component to your project. You can then import it like this:
|
||||
|
||||
```tsx {1,6} showLineNumbers title="app/routes/index.tsx"
|
||||
import { Button } from "~/components/ui/button"
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<div>
|
||||
<Button>Click me</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
</Steps>
|
||||
44
apps/v4/content/docs/installation/tanstack-router.mdx
Normal file
44
apps/v4/content/docs/installation/tanstack-router.mdx
Normal file
@@ -0,0 +1,44 @@
|
||||
---
|
||||
title: TanStack Router
|
||||
description: Install and configure shadcn/ui for TanStack Router.
|
||||
---
|
||||
|
||||
<Steps>
|
||||
|
||||
### Create project
|
||||
|
||||
Start by creating a new TanStack Router project:
|
||||
|
||||
```bash
|
||||
npx create-tsrouter-app@latest my-app --template file-router --tailwind --add-ons shadcn
|
||||
```
|
||||
|
||||
### Add Components
|
||||
|
||||
You can now start adding components to your project.
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add button
|
||||
```
|
||||
|
||||
The command above will add the `Button` component to your project. You can then import it like this:
|
||||
|
||||
```tsx title="src/routes/index.tsx" showLineNumbers {3,12}
|
||||
import { createFileRoute } from "@tanstack/react-router"
|
||||
|
||||
import { Button } from "@/components/ui/button"
|
||||
|
||||
export const Route = createFileRoute("/")({
|
||||
component: App,
|
||||
})
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<div>
|
||||
<Button>Click me</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
</Steps>
|
||||
252
apps/v4/content/docs/installation/tanstack.mdx
Normal file
252
apps/v4/content/docs/installation/tanstack.mdx
Normal file
@@ -0,0 +1,252 @@
|
||||
---
|
||||
title: TanStack Start
|
||||
description: Install and configure shadcn/ui for TanStack Start.
|
||||
---
|
||||
|
||||
Choose the setup that matches your starting point.
|
||||
|
||||
<div className="mt-6 grid gap-4 sm:grid-cols-3 sm:gap-6">
|
||||
<LinkedCard
|
||||
href="#scaffold-with-create"
|
||||
className="items-start gap-1 p-6 text-sm md:p-6"
|
||||
>
|
||||
<div className="font-medium">Use shadcn/create</div>
|
||||
<div className="leading-relaxed text-muted-foreground">
|
||||
Build your preset and generate a TanStack project command.
|
||||
</div>
|
||||
</LinkedCard>
|
||||
<LinkedCard
|
||||
href="#scaffold-with-cli"
|
||||
className="items-start gap-1 p-6 text-sm md:p-6"
|
||||
>
|
||||
<div className="font-medium">Use the CLI</div>
|
||||
<div className="leading-relaxed text-muted-foreground">
|
||||
Scaffold a new TanStack project from the terminal.
|
||||
</div>
|
||||
</LinkedCard>
|
||||
<LinkedCard
|
||||
href="#existing-start-project"
|
||||
className="items-start gap-1 p-6 text-sm md:p-6"
|
||||
>
|
||||
<div className="font-medium">Existing Project</div>
|
||||
<div className="leading-relaxed text-muted-foreground">
|
||||
Configure shadcn/ui manually in an existing TanStack project.
|
||||
</div>
|
||||
</LinkedCard>
|
||||
</div>
|
||||
|
||||
<div id="scaffold-with-create" className="scroll-mt-24" />
|
||||
## Use shadcn/create
|
||||
|
||||
<Steps>
|
||||
|
||||
### Build Your Preset
|
||||
|
||||
Open [shadcn/create](/create?template=start) and build your preset visually. Choose your style, colors, fonts, icons, and more.
|
||||
|
||||
<Button asChild size="sm">
|
||||
<Link
|
||||
href="/create?template=start"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="mt-6 no-underline!"
|
||||
>
|
||||
Open shadcn/create
|
||||
</Link>
|
||||
</Button>
|
||||
|
||||
### Create Project
|
||||
|
||||
Click `Create Project`, choose your package manager, and copy the generated command.
|
||||
|
||||
The generated command will look similar to this:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest init --preset [CODE] --template start
|
||||
```
|
||||
|
||||
The exact command will include your selected options such as `--base`, `--monorepo`, or `--rtl`.
|
||||
|
||||
### Add Components
|
||||
|
||||
Add the `Card` component to your project:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add card
|
||||
```
|
||||
|
||||
If you created a monorepo, run the command from `apps/web` or specify the workspace from the repo root:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add card -c apps/web
|
||||
```
|
||||
|
||||
The command above will add the `Card` component to your project. You can then import it like this:
|
||||
|
||||
```tsx showLineNumbers title="src/routes/index.tsx"
|
||||
import { createFileRoute } from "@tanstack/react-router"
|
||||
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card"
|
||||
|
||||
export const Route = createFileRoute("/")({
|
||||
component: App,
|
||||
})
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<Card className="max-w-sm">
|
||||
<CardHeader>
|
||||
<CardTitle>Project Overview</CardTitle>
|
||||
<CardDescription>
|
||||
Track progress and recent activity for your TanStack Start app.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
Your design system is ready. Start building your next component.
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
If you created a monorepo, update `apps/web/src/routes/index.tsx` and import from `@workspace/ui/components/card` instead.
|
||||
|
||||
</Steps>
|
||||
|
||||
<div id="scaffold-with-cli" className="scroll-mt-24" />
|
||||
## Use the CLI
|
||||
|
||||
<Steps>
|
||||
|
||||
### Create Project
|
||||
|
||||
Run the `init` command to scaffold a new TanStack Start project. Follow the prompts to configure your project: base, preset, monorepo, and more.
|
||||
|
||||
```bash
|
||||
npx shadcn@latest init -t start
|
||||
```
|
||||
|
||||
**For a monorepo project, use `--monorepo` flag:**
|
||||
|
||||
```bash
|
||||
npx shadcn@latest init -t start --monorepo
|
||||
```
|
||||
|
||||
### Add Components
|
||||
|
||||
Add the `Card` component to your project:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add card
|
||||
```
|
||||
|
||||
If you created a monorepo, run the command from `apps/web` or specify the workspace from the repo root:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add card -c apps/web
|
||||
```
|
||||
|
||||
The command above will add the `Card` component to your project. You can then import it like this:
|
||||
|
||||
```tsx showLineNumbers title="src/routes/index.tsx"
|
||||
import { createFileRoute } from "@tanstack/react-router"
|
||||
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card"
|
||||
|
||||
export const Route = createFileRoute("/")({
|
||||
component: App,
|
||||
})
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<Card className="max-w-sm">
|
||||
<CardHeader>
|
||||
<CardTitle>Project Overview</CardTitle>
|
||||
<CardDescription>
|
||||
Track progress and recent activity for your TanStack Start app.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
Your design system is ready. Start building your next component.
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
If you created a monorepo, update `apps/web/src/routes/index.tsx` and import from `@workspace/ui/components/card` instead.
|
||||
|
||||
</Steps>
|
||||
|
||||
<div id="existing-start-project" className="scroll-mt-24" />
|
||||
## Existing Project
|
||||
|
||||
<Steps>
|
||||
|
||||
### Create Project
|
||||
|
||||
If you need a new TanStack Start project, create one first. Otherwise, skip this step.
|
||||
|
||||
```bash
|
||||
npx @tanstack/cli@latest create
|
||||
```
|
||||
|
||||
Choose TanStack Start, the React framework, and the recommended defaults so Tailwind CSS and the `@/*` import alias are configured for you.
|
||||
|
||||
<Callout className="mt-6">
|
||||
|
||||
Do not add the `shadcn` add-on when prompted. The `shadcn` CLI will configure shadcn/ui later in this guide.
|
||||
|
||||
</Callout>
|
||||
|
||||
The TanStack CLI already configures Tailwind CSS and the default `@/*` import alias for you. If you're adding shadcn/ui to an older or custom TanStack Start app, make sure both are configured before continuing.
|
||||
|
||||
### Run the CLI
|
||||
|
||||
Run the `shadcn` init command to set up shadcn/ui in your project.
|
||||
|
||||
```bash
|
||||
npx shadcn@latest init
|
||||
```
|
||||
|
||||
### Add Components
|
||||
|
||||
You can now start adding components to your project.
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add button
|
||||
```
|
||||
|
||||
The command above will add the `Button` component to your project. You can then import it like this:
|
||||
|
||||
```tsx showLineNumbers title="src/routes/index.tsx"
|
||||
import { createFileRoute } from "@tanstack/react-router"
|
||||
|
||||
import { Button } from "@/components/ui/button"
|
||||
|
||||
export const Route = createFileRoute("/")({
|
||||
component: App,
|
||||
})
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<div className="flex min-h-svh items-center justify-center p-6">
|
||||
<Button>Click me</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
</Steps>
|
||||
314
apps/v4/content/docs/installation/vite.mdx
Normal file
314
apps/v4/content/docs/installation/vite.mdx
Normal file
@@ -0,0 +1,314 @@
|
||||
---
|
||||
title: Vite
|
||||
description: Install and configure shadcn/ui for Vite.
|
||||
---
|
||||
|
||||
Choose the setup that matches your starting point.
|
||||
|
||||
<div className="mt-6 grid gap-4 sm:grid-cols-3 sm:gap-6">
|
||||
<LinkedCard
|
||||
href="#scaffold-with-create"
|
||||
className="items-start gap-1 p-6 text-sm md:p-6"
|
||||
>
|
||||
<div className="font-medium">Use shadcn/create</div>
|
||||
<div className="leading-relaxed text-muted-foreground">
|
||||
Build your preset and generate a Vite project command.
|
||||
</div>
|
||||
</LinkedCard>
|
||||
<LinkedCard
|
||||
href="#scaffold-with-cli"
|
||||
className="items-start gap-1 p-6 text-sm md:p-6"
|
||||
>
|
||||
<div className="font-medium">Use the CLI</div>
|
||||
<div className="leading-relaxed text-muted-foreground">
|
||||
Scaffold a new Vite project directly from the terminal.
|
||||
</div>
|
||||
</LinkedCard>
|
||||
<LinkedCard
|
||||
href="#existing-vite-project"
|
||||
className="items-start gap-1 p-6 text-sm md:p-6"
|
||||
>
|
||||
<div className="font-medium">Existing Project</div>
|
||||
<div className="leading-relaxed text-muted-foreground">
|
||||
Configure shadcn/ui manually in an existing Vite project.
|
||||
</div>
|
||||
</LinkedCard>
|
||||
</div>
|
||||
|
||||
<div id="scaffold-with-create" className="scroll-mt-24" />
|
||||
## Use shadcn/create
|
||||
|
||||
<Steps>
|
||||
|
||||
### Build Your Preset
|
||||
|
||||
Open [shadcn/create](/create?template=vite) and build your preset visually. Choose your style, colors, fonts, icons, and more.
|
||||
|
||||
<Button asChild size="sm">
|
||||
<Link
|
||||
href="/create?template=vite"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="mt-6 no-underline!"
|
||||
>
|
||||
Open shadcn/create
|
||||
</Link>
|
||||
</Button>
|
||||
|
||||
### Create Project
|
||||
|
||||
Click `Create Project`, choose your package manager, and copy the generated command.
|
||||
|
||||
The generated command will look similar to this:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest init --preset [CODE] --template vite
|
||||
```
|
||||
|
||||
The exact command will include your selected options such as `--base`, `--monorepo`, or `--rtl`.
|
||||
|
||||
### Add Components
|
||||
|
||||
Add the `Card` component to your project:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add card
|
||||
```
|
||||
|
||||
If you created a monorepo, run the command from `apps/web` or specify the workspace from the repo root:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add card -c apps/web
|
||||
```
|
||||
|
||||
The command above will add the `Card` component to your project. You can then import it like this:
|
||||
|
||||
```tsx showLineNumbers title="src/App.tsx"
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card"
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<Card className="max-w-sm">
|
||||
<CardHeader>
|
||||
<CardTitle>Project Overview</CardTitle>
|
||||
<CardDescription>
|
||||
Track progress and recent activity for your Vite app.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
Your design system is ready. Start building your next component.
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
|
||||
export default App
|
||||
```
|
||||
|
||||
If you created a monorepo, update `apps/web/src/App.tsx` and import from `@workspace/ui/components/card` instead.
|
||||
|
||||
</Steps>
|
||||
|
||||
<div id="scaffold-with-cli" className="scroll-mt-24" />
|
||||
## Use the CLI
|
||||
|
||||
<Steps>
|
||||
|
||||
### Create Project
|
||||
|
||||
Run the `init` command to scaffold a new Vite project. Follow the prompts to configure your project: base, preset, monorepo, and more.
|
||||
|
||||
```bash
|
||||
npx shadcn@latest init -t vite
|
||||
```
|
||||
|
||||
**For a monorepo project, use `--monorepo` flag:**
|
||||
|
||||
```bash
|
||||
npx shadcn@latest init -t vite --monorepo
|
||||
```
|
||||
|
||||
### Add Components
|
||||
|
||||
Add the `Card` component to your project:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add card
|
||||
```
|
||||
|
||||
If you created a monorepo, run the command from `apps/web` or specify the workspace from the repo root:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add card -c apps/web
|
||||
```
|
||||
|
||||
The command above will add the `Card` component to your project. You can then import it like this:
|
||||
|
||||
```tsx showLineNumbers title="src/App.tsx"
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card"
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<Card className="max-w-sm">
|
||||
<CardHeader>
|
||||
<CardTitle>Project Overview</CardTitle>
|
||||
<CardDescription>
|
||||
Track progress and recent activity for your Vite app.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
Your design system is ready. Start building your next component.
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
|
||||
export default App
|
||||
```
|
||||
|
||||
If you created a monorepo, update `apps/web/src/App.tsx` and import from `@workspace/ui/components/card` instead.
|
||||
|
||||
</Steps>
|
||||
|
||||
<div id="existing-vite-project" className="scroll-mt-24" />
|
||||
## Existing Project
|
||||
|
||||
<Steps>
|
||||
|
||||
### Create Project
|
||||
|
||||
If you need a new Vite project, create one first and select the **React + TypeScript** template. Otherwise, skip this step.
|
||||
|
||||
```bash
|
||||
npm create vite@latest
|
||||
```
|
||||
|
||||
### Add Tailwind CSS
|
||||
|
||||
If your project already has Tailwind CSS configured, skip this step.
|
||||
|
||||
```bash
|
||||
npm install tailwindcss @tailwindcss/vite
|
||||
```
|
||||
|
||||
Replace everything in `src/index.css` with the following:
|
||||
|
||||
```css title="src/index.css"
|
||||
@import "tailwindcss";
|
||||
```
|
||||
|
||||
### Edit tsconfig.json file
|
||||
|
||||
If your project already has the `@/*` alias configured, skip this step.
|
||||
|
||||
Vite splits TypeScript configuration across multiple files. Add the `baseUrl` and `paths` properties to the `compilerOptions` section of `tsconfig.json` and `tsconfig.app.json`:
|
||||
|
||||
```ts title="tsconfig.json" {11-16} showLineNumbers
|
||||
{
|
||||
"files": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.app.json"
|
||||
},
|
||||
{
|
||||
"path": "./tsconfig.node.json"
|
||||
}
|
||||
],
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Edit tsconfig.app.json file
|
||||
|
||||
Add the same alias to `tsconfig.app.json` so your editor can resolve imports:
|
||||
|
||||
```ts title="tsconfig.app.json" {4-9} showLineNumbers
|
||||
{
|
||||
"compilerOptions": {
|
||||
// ...
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": [
|
||||
"./src/*"
|
||||
]
|
||||
}
|
||||
// ...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Update vite.config.ts
|
||||
|
||||
Install `@types/node` and update `vite.config.ts` so Vite can resolve the `@` alias:
|
||||
|
||||
```bash
|
||||
npm install -D @types/node
|
||||
```
|
||||
|
||||
```typescript title="vite.config.ts" showLineNumbers {1,2,8-13}
|
||||
import path from "path"
|
||||
import tailwindcss from "@tailwindcss/vite"
|
||||
import react from "@vitejs/plugin-react"
|
||||
import { defineConfig } from "vite"
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react(), tailwindcss()],
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": path.resolve(__dirname, "./src"),
|
||||
},
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
### Run the CLI
|
||||
|
||||
Run the `shadcn` init command to set up shadcn/ui in your project:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest init
|
||||
```
|
||||
|
||||
### Add Components
|
||||
|
||||
You can now start adding components to your project.
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add button
|
||||
```
|
||||
|
||||
The command above will add the `Button` component to your project. You can then import it like this:
|
||||
|
||||
```tsx showLineNumbers title="src/App.tsx"
|
||||
import { Button } from "@/components/ui/button"
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<div className="flex min-h-svh flex-col items-center justify-center">
|
||||
<Button>Click me</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default App
|
||||
```
|
||||
|
||||
</Steps>
|
||||
Reference in New Issue
Block a user