Search by

Composable Blade components for Laravel 13 and Livewire 4.

Package info

github.com/esoboy/ui

pkg:composer/esoboy/ui

Statistics

Installs: 46

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v2.2.1 2026-12-01 15:19 UTC

README

Composable, zero-class Blade UI components for Laravel 13, Livewire 4, Alpine.js, and Tailwind CSS v4.

Features

  • Blade-first & @blaze ready — Structural DOM rendered in Blade with zero internal Livewire components and zero global config files.
  • Zero-class CSS architecture — All component styles live in @layer components with zero class selectors, zero hardcoded colors outside theme.css, and [data-slot] / data-* state attributes, so host Tailwind utilities override cleanly without tailwind-merge.
  • Tailwind CSS v4 @theme default tokens — Customize surfaces, overlays, status colors, radii, shadows, and control heights directly in your host @theme, with pure @variant dark dark mode (no .dark class assumption).
  • Zero-dependency Alpine plugin (dist/ui.js) — Native <dialog>, Popover API, Livewire 4 x-anchor / x-collapse, and lightweight step validation for <x-ui::questionnaire>.
  • Livewire 4 first-class form controls — Direct wire:model* / x-modelable binding across all controls (including Toggle, ToggleGroup, FileUpload, and Editor) with unified change events, scoped <x-ui::field> FieldContext inheritance, and automatic Laravel $errors invalid state.
  • First-class Laravel integrations — Direct paginate() / simplePaginate() / cursorPaginate() support in Pagination and DataTable, Livewire WithFileUploads FileUpload, Blade-rendered MediaPreview, PHP-side Toast (Livewire & Session flash), bacon/bacon-qr-code SVG QrCode, and on-demand standalone Tiptap Editor (@assets data-navigate-once).
  • Laravel Boost ready — Ships with resources/boost/guidelines/core.blade.php and resources/boost/skills/esoboy-ui-development/ for AI-assisted development.

Requirements

  • PHP ^8.4
  • Laravel ^13.0
  • Livewire ^4.4
  • Tailwind CSS ^4.0

Installation

composer require esoboy/ui

1. Import Styles (resources/css/app.css)

@import 'tailwindcss';
@import '../../vendor/esoboy/ui/dist/ui.css';

@custom-variant dark (&:where(.dark, .dark *));

Customize theme tokens directly in your host @theme. All 6 palettes (primary, neutral, info, success, warning, danger) use the same 8-role base → derived model: overriding the base seed (and optionally -foreground) automatically generates -hover, -active, -subtle, -subtle-hover, -border, and -text across both light and dark modes, while any derived token can still be overridden individually:

@theme {
    --color-primary: oklch(0.55 0.22 262);
    --color-primary-foreground: #ffffff;
    /* Optional: override a single derived role while keeping the rest auto-derived */
    /* --color-primary-text: oklch(0.45 0.22 262); */
    --radius-control: 0.5rem;
}

2. Register Alpine Plugin (resources/js/app.js)

import '../../vendor/esoboy/ui/dist/ui.js'

dist/ui.js automatically registers all Alpine.data modules idempotently on alpine:init (or on an existing window.Alpine).

3. Optional: Publish Standalone Editor Assets

<x-ui::editor> loads its standalone editor.css and editor.js bundles on demand via a package asset route with content-hashed immutable caching. To serve them directly from public/vendor/esoboy/ui/:

php artisan vendor:publish --tag=ui-assets

Quick Start

Forms & Validation

<x-ui::field name="role" required>
    <x-ui::field.label>Role</x-ui::field.label>
    <x-ui::select wire:model="role" clearable>
        <x-ui::select.option value="admin">Administrator</x-ui::select.option>
        <x-ui::select.option value="editor">Editor</x-ui::select.option>
    </x-ui::select>
    <x-ui::field.description>Controls dashboard permissions.</x-ui::field.description>
    <x-ui::field.error />
</x-ui::field>

PHP-Side Toast Notifications

Place <x-ui::toaster /> once in your layout:

<x-ui::toaster position="bottom-right" />

Trigger, update, or dismiss toasts from Livewire 4 components or HTTP controllers:

use Esoboy\Ui\Support\Toast;

// Inside a Livewire 4 component
$id = Toast::to($this)->loading('Exporting report...', id: 'export');
Toast::to($this)->success('Report ready', id: $id);
Toast::to($this)->dismiss($id);

// Inside a controller before redirect
Toast::success('Settings saved');
return redirect()->route('settings');

DataTable & Laravel Pagination

<x-ui::data-table wire:model="selected" persist="users-table">
    <x-ui::data-table.filters
        collapsible
        default-collapsed
        clearable
        :active-count="$this->activeFilterCount"
        :collapsed-active-count="$this->collapsedFilterCount"
    >
        <x-slot:primary>
            <x-ui::input wire:model.live.debounce.300ms="search" size="sm" placeholder="Search users..." clearable />
        </x-slot:primary>
        <x-slot:toolbar>
            <x-ui::data-table.column-toggle />
        </x-slot:toolbar>
        <x-slot:collapsed>
            <x-ui::select wire:model.live="status" size="sm" placeholder="Status" clearable>
                <x-ui::select.option value="active">Active</x-ui::select.option>
                <x-ui::select.option value="inactive">Inactive</x-ui::select.option>
            </x-ui::select>
        </x-slot:collapsed>
    </x-ui::data-table.filters>

    <x-ui::data-table.table>
        <x-ui::data-table.columns>
            <x-ui::data-table.column-select pin="start" />
            <x-ui::data-table.column name="name" sortable :sorted="$sortBy === 'name'" :direction="$sortDirection" wire:click="sort('name')">Name</x-ui::data-table.column>
            <x-ui::data-table.column name="status" hideable>Status</x-ui::data-table.column>
        </x-ui::data-table.columns>

        <x-ui::data-table.rows>
            @forelse ($this->users as $user)
                <x-ui::data-table.row :key="$user->id" wire:key="user-{{ $user->id }}">
                    <x-ui::data-table.cell-select :value="$user->id" pin="start" />
                    <x-ui::data-table.cell name="name">{{ $user->name }}</x-ui::data-table.cell>
                    <x-ui::data-table.cell name="status">
                        <x-ui::badge :status="$user->active ? 'success' : 'neutral'">
                            {{ $user->active ? 'Active' : 'Inactive' }}
                        </x-ui::badge>
                    </x-ui::data-table.cell>
                </x-ui::data-table.row>
            @empty
                <x-ui::data-table.empty>No users found.</x-ui::data-table.empty>
            @endforelse
        </x-ui::data-table.rows>
    </x-ui::data-table.table>

    <x-ui::data-table.selection-bar select-all-action="selectAllMatching" :total="$this->users->total()">
        <x-ui::button size="xs" status="danger" wire:click="deleteSelected">Delete Selected</x-ui::button>
    </x-ui::data-table.selection-bar>

    <x-ui::data-table.footer :paginator="$this->users" livewire>
        <x-ui::data-table.count />
        <x-ui::data-table.page-rows wire:model.live="perPage" :options="$this->perPageOptions()" />
        <x-ui::data-table.pagination jumpable />
    </x-ui::data-table.footer>
</x-ui::data-table>

<x-ui::pagination :paginator="$posts" livewire />

File Upload

<x-ui::field name="attachments" required>
    <x-ui::field.label>Attachments</x-ui::field.label>
    <x-ui::file-upload wire:model="attachments" multiple accept="image/*,.pdf" max-size="5MB" :max-files="5" />
    <x-ui::field.error />
</x-ui::field>

Design Contract

  • Orthogonal variant, status, and state: variant is semantically named per component function with consistent naming across peer components (surface controls share default/secondary/outline/ghost/link, tabs use default/line, sidebar uses sidebar/floating/inset, etc.) and never encodes status colors; status (neutral, info, success, warning, danger) controls semantic color (Toggle, ToggleGroup, and Item do not accept status); workflow progression (Steps.Item, Trace) uses state (data-state).
  • Unified size scale: Always uses ordered tokens (xs, sm, md, lg, etc. — default md, with AlertDialog and Sheet defaulting to sm; ButtonGroup and Drawer do not take size; never default/base/normal). File sizes on <x-ui::attachment> use file-size.
  • Div-based triggers & close wrappers: All component triggers and overlay close/action wrappers (including popover.close) render a <div> layout container so the host application controls the inner interactive elements freely without nested <button> conflicts.
  • Zero content processing: <x-ui::rich-text> provides read-only typography styling only; host applications handle Markdown conversion and HTML sanitization.

License

Released under the MIT License.