React Router
Install shadcn/ui in React Router with the official CLI. Framework mode, the ~/ alias, then add a component from the shadcn.io registry.
init -t react-router scaffolds the app. create-react-router already sets Tailwind and ~/*. Imports in this stack are ~/components/ui/…, not @/.
Use the CLI
Create the project
npx shadcn@latest init -t react-routerMonorepo:
npx shadcn@latest init -t react-router --monorepoAdd a component
npx shadcn@latest add https://www.shadcn.io/r/card.jsonMonorepo: from apps/web, or -c apps/web from the root.
Import it
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>
)
}Monorepo: apps/web/app/routes/home.tsx, import @workspace/ui/components/card.
Existing project
Create the app if you need one
npm create react-router@latestTailwind and ~/* are already configured. Skip this if the repo exists.
Run init
npx shadcn@latest initAdd a component
npx shadcn@latest add https://www.shadcn.io/r/button.jsonimport { 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>
)
}This is not Remix
Remix has its own guide. React Router v7 is the framework these commands target.
Questions
Related
Was this page helpful?
Sign in to leave feedback.