组件
创建项目
pnpm dlx create-react-router@latest my-app
运行 CLI
运行 shadcn
init 命令来设置你的项目
pnpm dlx shadcn@latest init
添加组件
你现在可以开始向你的项目添加组件了。
pnpm dlx shadcn@latest add button
上述命令会将 Button
组件添加到你的项目。然后你可以像这样导入它
import { Button } from "~/components/ui/button"
import type { Route } from "./+types/home"
export function meta({}: Route.MetaArgs) {
return [
{ title: "New React Router App" },
{ name: "description", content: "Welcome to React Router!" },
]
}
export default function Home() {
return (
<div className="flex min-h-svh flex-col items-center justify-center">
<Button>Click me</Button>
</div>
)
}