Docs
Laravel
Laravel
Install and configure Laravel with Inertia
Create project
Start by creating a new Laravel project with Inertia and React using the laravel installer laravel new my-app
:
laravel new my-app --typescript --breeze --stack=react --git --no-interaction
Run the CLI
Run the pm-ui
init command to setup your project:
npx @pujan-modha/pm-ui init
Configure components.json
You will be asked a few questions to configure components.json
:
Would you like to use TypeScript (recommended)? no / yes
Where is your global CSS file? › resources/css/app.css
Where is your tailwind.config.ts located? › tailwind.config.ts
Configure the import alias for components: › @/Components
Configure the import alias for utils: › @/lib/utils
Are you using React Server Components? › no / yes
Update tailwind.config.js
The pm-ui
CLI will automatically overwrite your tailwind.config.js
. Update it to look like this:
import forms from "@tailwindcss/forms"
import defaultTheme from "tailwindcss/defaultTheme"
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php",
"./storage/framework/views/*.php",
"./resources/views/**/*.blade.php",
"./resources/js/**/*.tsx",
],
theme: {
container: {
center: true,
padding: "2rem",
screens: {
"2xl": "1400px",
},
},
extend: {
colors: {
background: "hsl(var(--background))",
foreground: "hsl(var(--foreground))",
primary: "hsl(var(--primary))",
destructive: "hsl(var(--destructive))",
popover: "hsl(var(--popover))",
},
fontFamily: {
sans: ["Figtree", ...defaultTheme.fontFamily.sans],
},
keyframes: {
"accordion-down": {
from: { height: "0" },
to: { height: "var(--radix-accordion-content-height)" },
},
"accordion-up": {
from: { height: "var(--radix-accordion-content-height)" },
to: { height: "0" },
},
"caret-blink": {
"0%,70%,100%": { opacity: "1" },
"20%,50%": { opacity: "0" },
},
},
animation: {
"accordion-down": "accordion-down 0.2s ease-out",
"accordion-up": "accordion-up 0.2s ease-out",
"caret-blink": "caret-blink 1.25s ease-out infinite",
},
},
},
plugins: [forms, require("tailwindcss-animate")],
}
That's it
You can now start adding components to your project.
npx @pujan-modha/pm-ui add 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>
)
}