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/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>
|
||||
Reference in New Issue
Block a user