Laravel
Install shadcn/ui in Laravel with the React starter kit. laravel new, then the official CLI, then add a component from the shadcn.io registry.
The shadcn CLI does not scaffold a Laravel app. Create one with the React starter kit, then init from the project root. Components land in resources/js/components/ui.
Create the Laravel app
Skip if you already have Laravel + Inertia + React.
laravel new my-appChoose the React starter kit. See the Laravel frontend docs.
cd my-appUse the CLI
Run init
From the Laravel root:
npx shadcn@latest initOverwrite components.json and existing components when asked — Yes.
Add a component
npx shadcn@latest add https://www.shadcn.io/r/switch.jsonFile: resources/js/components/ui/switch.tsx.
Import it
import { Switch } from "@/components/ui/switch"
const MyPage = () => {
return (
<div>
<Switch />
</div>
)
}
export default MyPageNo -t laravel
init -t does not create a Laravel app. laravel new first, then init with no template.
Questions
Related
Was this page helpful?
Sign in to leave feedback.