Installation Add the package via Composer:
composer require lundholm.dev/shadcn-ui-blade
Publish the Blade components (if needed):
php artisan vendor:publish --provider="LundholmDev\ShadcnUiBlade\ShadcnUiBladeServiceProvider" --tag="shadcn-ui-blade"
(Note: Check the latest docs for updated publish tags or config options.)
First Use Case Use a pre-built component in a Blade view:
<x-shadcn-button>
Click Me
</x-shadcn-button>
(Verify the component name matches the package’s naming convention—e.g., shadcn-button, shadcn-input.)
Where to Look First
README.md for component lists, customization guides, and CLI tools (if available).resources/views/vendor/shadcn-ui-blade/ for default templates.tailwind.config.js includes the package’s required classes (e.g., @shadcn/ui prefix).Component Composition Nest components for complex UIs:
<x-shadcn-card>
<x-slot name="header">
<h3>Header</h3>
</x-slot>
<x-shadcn-button>Action</x-shadcn-button>
</x-shadcn-card>
(Use x-slot for named slots, like header, footer, or default.)
Dynamic Props Pass props via Blade syntax:
<x-shadcn-button type="submit" disabled="{{ $isLoading }}">
Submit
</x-shadcn-button>
(Check the package’s component docs for supported props—e.g., variant, size.)
Customization Override defaults by publishing and modifying the component files:
php artisan vendor:publish --tag="shadcn-ui-blade" --force
Edit files in resources/views/vendor/shadcn-ui-blade/components/.
Form Integration Use with Laravel Collective or native Blade forms:
<x-shadcn-input type="email" name="email" :value="old('email')">
<x-slot name="label">Email</x-slot>
</x-shadcn-input>
// tailwind.config.js
module.exports = {
theme: {
extend: {
colors: {
primary: {
DEFAULT: '#3b82f6',
// ... other variants
},
},
},
},
};
tailwind.config.js includes darkMode: 'class' and test components with dark: variants.<x-shadcn-button x-on:click="alert('Clicked!')">Alpine Button</x-shadcn-button>
<x-shadcn-input :error="$errors->has('email')">
<x-slot name="error">{{ $errors->first('email') }}</x-slot>
</x-shadcn-input>
$this->blade('<x-shadcn-button>Test</x-shadcn-button>')
->assertSee('button')
->assertSeeText('Test');
Component Naming
<x-shadcn-button> vs. <x-button>).README or published files.Missing Dependencies
@tailwind directives are in resources/css/app.css.Slot Conflicts
header, footer) may override unexpected content if not handled.<x-shadcn-card>
<x-slot name="header">Custom Header</x-slot>
<p>Content</p>
</x-shadcn-card>
Prop Binding
:disabled) may not work if the component uses static attributes.{{ }} syntax for simple bindings.vendor/lundholm-dev/shadcn-ui-blade/src/.!important sparingly; debug with Tailwind’s JIT mode or npx tailwindcss -i for errors.php artisan view:clear
public/ or node_modules/ locations.Create Custom Components
Extend the package by copying a base component (e.g., shadcn-button) and modifying it in resources/views/vendor/shadcn-ui-blade/components/.
<!-- resources/views/vendor/shadcn-ui-blade/components/shadcn-my-button.blade.php -->
<button class="bg-red-500 text-white p-2 rounded">
{{ $slot }}
</button>
Use it as <x-shadcn-my-button>.
Add New Components
Fork the package or submit PRs to add missing components (e.g., shadcn-dialog, shadcn-tooltip).
JavaScript Enhancements Augment components with Alpine.js or vanilla JS by extending their classes:
// resources/js/app.js
document.addEventListener('alpine:init', () => {
Alpine.data('shadcnButton', () => ({
click() { console.log('Custom logic'); }
}));
});
Then bind in Blade:
<x-shadcn-button x-data="shadcnButton()" x-on:click="click">Click</x-shadcn-button>
How can I help you explore Laravel packages today?