nasirkhan/laravel-cube
Laravel Cube provides reusable Blade UI components for Laravel with dual support for Tailwind CSS (Flowbite) and Bootstrap 5. Switch frameworks globally or per component, with dark mode, Livewire compatibility, and easy customization via published views.
Installation:
composer require nasirkhan/laravel-cube
Automatically registers the service provider.
Configure Default Framework:
Set CUBE_FRAMEWORK in .env to either tailwind or bootstrap.
Tailwind Setup (if using Tailwind CSS v4): Add to your main CSS file:
@import "../../vendor/nasirkhan/laravel-cube/resources/css/tailwind.css";
First Use Case: Use a basic button in a Blade view:
<x-cube::button variant="primary">Click Me</x-cube::button>
docs/icons.md for available icons and their usage.php artisan vendor:publish --tag=cube-views), inspect resources/views/vendor/cube/components/ for customization.Framework Agnostic Components: Use the same Blade component syntax regardless of the underlying CSS framework:
<!-- Uses Tailwind by default -->
<x-cube::button variant="primary">Default</x-cube::button>
<!-- Override per component -->
<x-cube::button framework="bootstrap" variant="primary">Bootstrap</x-cube::button>
Form Handling: Group form inputs with labels, errors, and validation:
<x-cube::group name="email" label="Email" required>
<x-cube::input type="email" name="email" :value="old('email')" required />
<x-cube::error :messages="$errors->get('email')" />
</x-cube::group>
Navigation: Use responsive navigation components with active state support:
<x-cube::nav-link href="{{ route('dashboard') }}" :active="request()->routeIs('dashboard')">
Dashboard
</x-cube::nav-link>
Icons: Embed icons with customizable variants and classes:
<x-cube::icon name="bell" variant="solid" class="text-red-500" />
Livewire Integration: Cube components work seamlessly with Livewire. Use them in Livewire views like any other Blade component.
Component-Based Development:
<x-cube::button variant="primary">.Theming:
resources/views/vendor/cube/components/button.blade.php.Dark Mode:
Progressive Adoption:
Tailwind CSS:
content configuration includes Cube’s views:
content: [
'./resources/views/**/*.blade.php',
'./vendor/nasirkhan/laravel-cube/resources/views/**/*.blade.php',
],
bg-blue-500 for buttons) directly in Blade.Bootstrap 5:
btn-primary).Livewire:
<x-cube::button wire:click="save" :loading="$processing">
Save
</x-cube::button>
Customization:
<!-- resources/views/vendor/cube/components/button.blade.php -->
@props(['customProp' => false])
<button {{ $attributes }}>
@if($customProp)
Custom Button
@else
{{ $slot }}
@endif
</button>
Tailwind CSS Setup:
@import "../../vendor/nasirkhan/laravel-cube/resources/css/tailwind.css") can break Tailwind-based components.Framework Mismatch:
bg-blue-500) in a Bootstrap component or vice versa.<x-cube::button framework="tailwind" class="bg-blue-500">Tailwind Button</x-cube::button>
Icon Availability:
docs/icons.md for the full list of available icons.Published Views Overwrite:
mergeConfigPath in config/cube.php to preserve customizations.Livewire Conflicts:
wire: directives may conflict if not properly scoped.Component Not Rendering:
<x-cube::button>).Styles Not Applying:
@import is in your CSS and Tailwind is scanning Cube’s views.Dark Mode Issues:
darkMode: 'class',
dark: variants to Cube’s published views if needed.Component Props:
php artisan vendor:publish --tag=cube-config to inspect available props for each component in config/cube.php.Dark Mode:
dark: classes to published views:
<button class="bg-blue-500 dark:bg-blue-700">
Performance:
Testing:
$this->blade('<x-cube::button>Test</x-cube::button>')->assertSee('button');
Custom Icons:
resources/views/vendor/cube/icons/.Framework-Specific Logic:
@if to conditionally render framework-specific markup:
@if($framework === 'tailwind')
<div class="p-4 bg-gray-100">
@else
<div class="p-4 bg-light">
@endif
Configuration:
config/cube.php:
'defaults' => [
'framework' => 'tailwind',
'button' => [
'size' => 'md',
],
],
Companion Packages:
nasirkhan/laravel-sharekit for social sharing without bloating Cube:
<x-sharekit::buttons :url="$post->url" />
How can I help you explore Laravel packages today?