nasirkhan/laravel-cube
Laravel Cube provides reusable Blade UI components with dual support for Tailwind CSS (Flowbite) and Bootstrap 5. Switch frameworks globally or per component, includes dark mode for Tailwind, Livewire-friendly, and easy to customize via published views.
composer require nasirkhan/laravel-cube
.env:
CUBE_FRAMEWORK=tailwind # or 'bootstrap'
@import "../../vendor/nasirkhan/laravel-cube/resources/css/tailwind.css";
<x-cube::button variant="primary">Click Me</x-cube::button>
php artisan vendor:publish --tag=cube-views
CUBE_FRAMEWORK in .env to default all components to Tailwind or Bootstrap.<x-cube::button framework="bootstrap">Bootstrap Button</x-cube::button>
<x-cube::group name="email" label="Email">
<x-cube::input type="email" name="email" />
<x-cube::error :messages="$errors->email" />
</x-cube::group>
<x-cube::button wire:click="save" :loading="processing">
Save
</x-cube::button>
loading prop for async states:
<x-cube::button :loading="true">Processing...</x-cube::button>
<x-cube::error :messages="$errors->get('field_name')" />
<x-cube::input name="email" :value="old('email')" />
<x-cube::group name="email" label="Email" required>
<x-cube::input type="email" name="email" required />
</x-cube::group>
<x-cube::nav-link href="{{ route('dashboard') }}" :active="request()->routeIs('dashboard')">
Dashboard
</x-cube::nav-link>
<x-cube::responsive-nav-link href="{{ route('profile') }}">
Profile
</x-cube::responsive-nav-link>
<x-cube::button variant="primary" class="dark:bg-gray-800">
Dark Button
</x-cube::button>
Tailwind CSS Setup:
tailwind.css from the package will break Tailwind-specific components.@import "../../vendor/nasirkhan/laravel-cube/resources/css/tailwind.css"; to your CSS file.Icon Naming:
adjustments-horizontal), not camelCase or snake_case.Framework Mismatch:
Published Views Overwrite:
php artisan vendor:publish --tag=cube-views --force to overwrite existing files.Component Not Rendering:
<x-cube::buton> vs <x-cube::button>).x-cube:: not x-cube.button).Styling Issues:
framework="tailwind" or framework="bootstrap" to debug per-component rendering.Livewire Conflicts:
composer require livewire/livewire).wire:model alongside Cube form components for two-way binding:
<x-cube::input wire:model="email" name="email" />
Customizing Components:
resources/views/vendor/cube/components/.vendor/nasirkhan/laravel-cube/resources/views/components/button.blade.php to your published views directory.Adding New Components:
app/View/Components.app/View/Components/Cube/NewComponent.php).Configuration Overrides:
php artisan vendor:publish --tag=cube-config
config/cube.php to change default settings (e.g., icon variants, button variants).Lazy-Loading Icons:
class="hidden" and add via JavaScript if icons are not critical for initial render.<x-cube::icon name="adjustments-horizontal" class="hidden icon-to-load" />
<script>
document.querySelector('.icon-to-load').classList.remove('hidden');
</script>
Component Caching:
php artisan view:cache
Tailwind Optimization:
npx tailwindcss -i input.css -o output.css --watch to purge unused CSS classes from Cube’s Tailwind components.Dynamic Framework Selection:
// app/Helpers/CubeHelper.php
function cubeFramework(): string {
return session('cube_framework') ?? config('cube.framework');
}
<x-cube::button framework="{{ cubeFramework() }}">Dynamic Button</x-cube::button>
Component Slots:
<x-cube::modal>
<x-slot name="title">Custom Title</x-slot>
Modal content here.
</x-cube::modal>
Integration with Laravel Sharekit:
@if($showShareButtons)
<x-sharekit::buttons :url="route('post.show', $post)" />
@endif
How can I help you explore Laravel packages today?