## Getting Started
### Minimal Setup
1. **Installation**:
```bash
composer require flux-clone/ui
The package auto-registers its service provider.
Tailwind Configuration:
Add the package's view path to your tailwind.config.js:
module.exports = {
content: [
// ... existing paths
"./vendor/flux-clone/ui/resources/views/**/*.blade.php",
],
}
Or for Tailwind 4 (CSS):
@source "../vendor/flux-clone/ui/resources/views/**/*.blade.php";
First Use Case:
Replace a basic form input with the package's <x-flux-clone::input>:
<x-flux-clone::input name="email" label="Email" type="email" />
This immediately adds label, error handling, and styling.
Validation Errors: The <x-flux-clone::input> component automatically handles Laravel validation errors via $errors:
<x-flux-clone::input name="email" label="Email" type="email" />
Errors render below the input with red styling.
Livewire Forms: Pair with Livewire for reactive forms:
<x-flux-clone::input wire:model="email" label="Email" />
Named Modals: Use Alpine.js for modal management:
<x-flux-clone::modal name="confirm-delete">
<!-- Modal content -->
</x-flux-clone::modal>
<x-flux-clone::modal.trigger name="confirm-delete">
<x-flux-clone::button variant="danger">Delete</x-flux-clone::button>
</x-flux-clone::modal.trigger>
Triggers can be buttons, links, or other components.
Livewire Modals: Combine with Livewire for dynamic content:
<x-flux-clone::modal wire:model="showModal">
<x-flux-clone::heading>Edit User</x-flux-clone::heading>
<x-flux-clone::input wire:model="name" label="Name" />
</x-flux-clone::modal>
sortable attribute to enable client-side sorting:
<x-flux-clone::table>
<x-flux-clone::table.head>
<x-flux-clone::table.row>
<x-flux-clone::table.cell header sortable="name">Name</x-flux-clone::table.cell>
</x-flux-clone::table.row>
</x-flux-clone::table.head>
<!-- ... -->
</x-flux-clone::table>
For server-side sorting, bind to a Livewire property (e.g., wire:click="sortBy('name')").Card Components: Use <x-flux-clone::card> for consistent card layouts:
<x-flux-clone::card>
<x-flux-clone::heading>User Profile</x-flux-clone::heading>
<x-flux-clone::text>John Doe</x-flux-clone::text>
</x-flux-clone::card>
Cards include padding, shadows, and responsive behavior.
Navigation: Build navbars and navlists for consistent UI:
<x-flux-clone::navbar>
<x-flux-clone::navlist>
<x-flux-clone::navlist.item href="/dashboard">Dashboard</x-flux-clone::navlist.item>
</x-flux-clone::navlist>
</x-flux-clone::navbar>
Icons: Use Heroicons via Blade Icons:
<x-flux-clone::icon name="check-circle" variant="solid" />
Requires blade-ui-kit/blade-heroicons.
Callouts: Display alerts with <x-flux-clone::callout>:
<x-flux-clone::callout type="success">
User created successfully!
</x-flux-clone::callout>
Types: info, success, warning, danger.
tailwind.config.js.dark class or use JavaScript to toggle it:
document.documentElement.classList.toggle("dark");
name="confirm-delete") require Alpine.js. If using Livewire, prefer wire:model for modals to avoid conflicts:
<x-flux-clone::modal wire:model="showModal">
<!-- Content -->
</x-flux-clone::modal>
viewable attribute on <x-flux-clone::input> toggles password visibility with an eye icon. Ensure Alpine.js is loaded (included with Livewire).$errors helper. If errors don't display, verify:
name matches the validation rule.sortable attribute enables basic sorting. For server-side sorting, manually bind to Livewire methods:
<x-flux-clone::table.cell
header
wire:click="sort('name')"
class="cursor-pointer"
>
Name
</x-flux-clone::table.cell>
Publish Views:
php artisan vendor:publish --tag=flux-clone-views
Override components in resources/views/vendor/flux-clone.
Extending Variants:
Add custom button variants by extending the component's Tailwind classes. For example, create a secondary variant in your published view:
@props(['variant' => 'primary'])
<button class="px-4 py-2 rounded-md {{ $variant === 'secondary' ? 'bg-blue-100 text-blue-800' : '' }}">
{{ $slot }}
</button>
<x-flux-clone::input>) and adapt them for new use cases.x-data, x-show, and x-transition.<x-flux-clone::table>
@foreach($users->chunk(10) as $chunk)
<!-- Render chunk -->
@endforeach
</x-flux-clone::table>
<x-flux-clone::input
wire:model.debounce.500ms="search"
label="Search"
/>
public function test_button_renders()
{
$component = Blade::render('<x-flux-clone::button>Click</x-flux-clone::button>');
$this->assertStringContainsString('Click', $component);
}
public function test_modal_with_livewire()
{
$this->livewire(ModalComponent::class)
->assertSee('Modal Title');
}
tailwind.config.js:
theme: {
extend: {
colors: {
primary: {
500: '#3b82f6',
900: '#1d4ed8',
},
},
},
},
Then use bg-primary-500 dark:bg-primary-900 in components.blade-ui-kit/blade-heroicons. Without it, icons will render as text.<x-flux-clone::icon> component with a fallback:
How can I help you explore Laravel packages today?