组件
开始一个新项目? 使用 shadcn/create 来创建一个完全配置好的 React Router 应用,包含自定义主题、Base UI 或 Radix,以及图标库。
创建项目
🌐 Create project
pnpm dlx shadcn@latest init -t react-router
对于单仓库项目,请使用 --monorepo 标志:
pnpm dlx shadcn@latest init -t react-router --monorepo
添加组件
🌐 Add Components
你现在可以开始向你的项目添加组件。
🌐 You can now start adding components to your project.
pnpm dlx shadcn@latest add button
上面的命令将会把 Button 组件添加到你的项目中。然后你可以这样导入它:
🌐 The command above will add the Button component to your project. You can then import it like this:
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>
)
}