Installation:
composer require ilsyaa/lazyui
Publish the package assets (Blade components + Tailwind config) via:
php artisan vendor:publish --provider="Ilsyaa\LazyUI\LazyUIServiceProvider" --tag="lazyui-assets"
Add @lazyui directive to your resources/views/layouts/app.blade.php (or equivalent) to load the base styles.
First Component:
Use the pre-built lazyui-card component in a Blade view:
<x-lazyui-card title="User Profile" icon="user">
<p>Hello, {{ $user->name }}!</p>
</x-lazyui-card>
Verify the component renders with Tailwind styling (e.g., rounded corners, shadow, padding).
Livewire Integration:
For Livewire components, extend the base LazyUIComponent:
use Ilsyaa\LazyUI\Components\LazyUIComponent;
class UserProfile extends LazyUIComponent {
public $user;
// ...
}
Register in app/Providers/LazyUIServiceProvider.php:
public function boot() {
LazyUI::component('user-profile', UserProfile::class);
}
Blade Components:
<x-lazyui-button type="primary" :loading="$isProcessing">
Save Changes
</x-lazyui-button>
<x-lazyui-modal>
<x-slot name="title">Confirm Action</x-slot>
<p>Are you sure?</p>
</x-lazyui-modal>
Livewire Components:
public $isOpen = false;
public $items = [];
$this->emit('modalClosed');
lazyui-form with Livewire validation:
<x-lazyui-form wire:submit.prevent="save">
<!-- Fields -->
</x-lazyui-form>
Customization:
class attribute:
<x-lazyui-card class="bg-blue-500 text-white">
Custom Styling
</x-lazyui-card>
class CustomCard extends LazyUICard {
public $footer = null;
}
Integration with Laravel Features:
lazyui-auth components for login/register:
<x-lazyui-auth.login />
$this->dispatch('alert', type: 'success', message: 'Saved!');
Asset Loading:
@lazyui directive is in the <head> of your layout. Clear cached views:
php artisan view:clear
Livewire Component Registration:
LazyUIServiceProvider after Livewire’s boot:
public function boot() {
Livewire::component('custom-component', CustomComponent::class);
LazyUI::component('custom-component', CustomComponent::class);
}
Tailwind Conflicts:
!important sparingly. Prefer scoped classes:
<x-lazyui-button class="!bg-red-600"> <!-- Last resort -->
State Persistence:
persist() for critical data:
public function mount() {
$this->persist('isOpen');
}
lazyui-base) are loaded.config/livewire.php:
'log' => env('LIVEWIRE_LOG', true),
Custom Components:
LazyUIComponent) to add shared logic.LazyUIDataTable by combining LazyUIComponent with a library like Tabler.Theme Overrides:
resources/css/lazyui.css to override default styles globally.@layer directives for Tailwind 3+:
@layer components.lazyui-button {
.lazyui-button {
@apply bg-indigo-600;
}
}
Dark Mode:
dark: classes. Ensure your layout includes:
<x-lazyui-dark-mode />
Localization:
config/lazyui.php:
'labels' => [
'cancel' => __('buttons.cancel'),
],
wire:ignore and lazy-load content:
<div wire:ignore>
<x-lazyui-heavy-component wire:init="loadHeavyData" />
</div>
@import in custom CSS to prevent bloat.null for optional props. Explicitly set defaults in Livewire:
public $size = 'md'; // Overrides default
<x-slot name="footer" :default="__('buttons.save')" />
```markdown
## Additional Notes
- **Community**: Join the [LazyUI Discord](https://discord.gg/lazyui) for support.
- **Changelog**: Review `CHANGELOG.md` for breaking changes between versions (e.g., Livewire 3.x migration).
- **Testing**: Use `php artisan lazyui:test` to validate component rendering (if included in future updates).
How can I help you explore Laravel packages today?