Docs
Next.js
Next.js
安装并配置 Next.js。
如果你使用的是 Next.js 15,请参阅 Next.js 15 + React 19 指南。
¥If you're using Next.js 15, see the Next.js 15 + React 19 guide.
创建项目
¥Create project
运行 init
命令以创建新的 Next.js 项目或设置现有项目:
¥Run the init
command to create a new Next.js project or to setup an existing one:
pnpm dlx shadcn@latest init
你可以将 -d
标志用于默认值,即 new-york
、zinc
和 yes
用于 css 变量。
¥You can use the -d
flag for defaults i.e new-york
, zinc
and yes
for the css variables.
pnpm dlx shadcn@latest init -d
配置 components.json
¥Configure components.json
你将被问到几个问题来配置 components.json
:
¥You will be asked a few questions to configure 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
就是这样
¥That's it
你现在可以开始向你的项目添加组件。
¥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"
export default function Home() {
return (
<div>
<Button>Click me</Button>
</div>
)
}