Docs
Next.js
Next.js
安装并配置 Next.js。
Update: We have added full support for React 19 and Tailwind v4 in the
canary
release. See the docs for Tailwind v4 for more
information.
创建项目
运行 init
命令创建新的 Next.js 项目或设置现有项目:
pnpm dlx shadcn@latest init
你可以使用 -d
标志来设置默认值,例如 new-york
、zinc
和 yes
( 使用 css 变量)。
pnpm dlx shadcn@latest init -d
配置 components.json
配置 components.json
时会问你几个问题:
Which style would you like to use? › New York
Which color would you like to use as base color? › Zinc
Do you want to use CSS variables for colors? › no / yes
就这样
现在你可以开始为你的项目添加组件了。
pnpm dlx shadcn@latest add button
执行上面的命令后会将 Button
组件添加到项目中。然后你就可以像这样导入(import)它了:
import { Button } from "@/components/ui/button"
export default function Home() {
return (
<div>
<Button>Click me</Button>
</div>
)
}