Installation
composer require forlaravel/lux
Publish the package assets (Blade components, Tailwind config, and any default views):
php artisan vendor:publish --provider="ForLaravel\Lux\LuxServiceProvider" --tag="lux-assets"
Tailwind Integration
Ensure your tailwind.config.js includes Lux’s default theme (or extend it):
module.exports = {
theme: {
extend: {
colors: {
primary: {
DEFAULT: '#3b82f6',
// ... other Lux defaults
},
},
},
},
}
First Use Case Render a Lux button in a Blade view:
@luxButton('Click Me', 'primary')
Or use the full component syntax:
<x-lux.button type="primary">Click Me</x-lux.button>
button, card, modal, alert). Use them like native Blade components:
<x-lux.card>
<x-slot name="header">
<h3>Title</h3>
</x-slot>
Content here.
</x-lux.card>
<x-lux.modal>
<x-slot name="title">Confirm Action</x-slot>
Are you sure?
</x-lux.modal>
@luxButton('Save', 'success', ['class' => 'rounded-lg'])
tailwind.config.js:
module.exports = {
theme: {
extend: {
colors: {
danger: '#ef4444', // Override Lux's default
},
},
},
}
<x-lux.form>
<x-lux.input label="Email" name="email" type="email" />
<x-lux.button type="submit">Submit</x-lux.button>
</x-lux.form>
@if($errors->any())
<x-lux.alert type="error">
{{ $errors->first() }}
</x-lux.alert>
@endif
@luxButton($dynamicText, $dynamicVariant)
with() for complex data:
<x-lux.card :user="$user" />
(Ensure the component accepts $user in its props.)Tailwind Conflicts
resources/css/app.css.Component Registration
AppServiceProvider:
public function boot(): void {
Blade::component('lux.button', \ForLaravel\Lux\Components\Button::class);
}
Slot Naming
slot for default content and named slots (e.g., header, footer). Misnaming slots will break rendering.Dependency on shadcn/ui
{{ dd($props) }} inside a component’s Blade template to debug passed data.Custom Components
app/View/Components/Lux. Example:
namespace App\View\Components\Lux;
use ForLaravel\Lux\Components\BaseComponent;
class CustomButton extends BaseComponent { ... }
AppServiceProvider.Override Defaults
resources/views/vendor/lux/ to customize without modifying the package directly.Add New Variants
dark mode):
module.exports = {
darkMode: 'class',
theme: {
extend: {
colors: {
primary: {
dark: '#1e40af',
},
},
},
},
}
@once for heavy Lux components to avoid re-rendering:
@once
<x-lux.modal>...</x-lux.modal>
@endonce
php artisan view:cache
How can I help you explore Laravel packages today?