Docs
Laravel
Laravel
为 Laravel 安装并配置 shadcn/ui
注意:以下指南适用于 Tailwind v4。如果你使用的是 Tailwind v3,请使用 shadcn@2.3.0
。
¥Note: The following guide is for Tailwind v4. If you are using Tailwind
v3, use shadcn@2.3.0
.
创建项目
¥Create project
首先使用 laravel 安装程序 laravel new my-app
创建包含 Inertia 和 React 的新 Laravel 项目:
¥Start by creating a new Laravel project with Inertia and React using the laravel installer laravel new my-app
:
laravel new my-app --react
添加组件
¥Add Components
你现在可以开始向你的项目添加组件。
¥You can now start adding components to your project.
pnpm dlx shadcn@latest add switch
上述命令会将 Switch
组件添加到 resources/js/components/ui/switch.tsx
。然后你可以像这样导入它:
¥The command above will add the Switch
component to resources/js/components/ui/switch.tsx
. You can then import it like this:
import { Switch } from "@/components/ui/switch"
const MyPage = () => {
return (
<div>
<Switch />
</div>
)
}
export default MyPage