Make your AI a shadcn expert

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-app

Choose the React starter kit. See the Laravel frontend docs.

cd my-app

Use the CLI

Run init

From the Laravel root:

npx shadcn@latest init

Overwrite components.json and existing components when asked — Yes.

Add a component

npx shadcn@latest add https://www.shadcn.io/r/switch.json

File: resources/js/components/ui/switch.tsx.

Import it

resources/js/pages/index.tsx
import { Switch } from "@/components/ui/switch"

const MyPage = () => {
  return (
    <div>
      <Switch />
    </div>
  )
}

export default MyPage

No -t laravel

init -t does not create a Laravel app. laravel new first, then init with no template.

Questions

Was this page helpful?

Sign in to leave feedback.