beartropy/ui
Beartropy UI is a small Laravel UI package providing ready-made components and helpers to speed up building admin and front-end screens. Drop in common layouts, forms, and UI utilities to get a consistent look fast with minimal setup.
A toggle switch (checkbox alternative) with label support, colors, sizes, label positioning, validation errors, help text, and built-in autosave support.
<x-bt-toggle label="Enable notifications" />
<x-bt-toggle label="Dark mode" wire:model.live="darkMode" />
| Prop | Type | Default | Description |
|---|---|---|---|
name |
string|null |
null |
Input name attribute |
label |
string|null |
null |
Label text |
label-position |
string|null |
'right' |
Label placement: 'top', 'bottom', 'left', 'right' |
color |
string|null |
config default | Color preset name |
size |
string|null |
'md' |
Size preset name |
custom-error |
mixed |
null |
Custom error message (bypasses validation bag) |
disabled |
bool |
false |
Disabled state |
hint |
string|null |
null |
Help text below the toggle |
help |
string|null |
null |
Help text below the toggle (takes precedence over hint) |
autosave |
bool |
false |
Enable automatic server-side persistence |
autosave-method |
string |
'savePreference' |
Livewire method to call on toggle change |
autosave-key |
string|null |
wire:model value | Key passed to the autosave method |
autosave-debounce |
int |
300 |
Debounce delay in milliseconds |
Standard HTML attributes (id, checked, wire:model, etc.) are forwarded to the native <input>.
The label can be set via the label prop or the default slot. The slot takes precedence:
{{-- Simple label --}}
<x-bt-toggle label="Enable feature" />
{{-- Rich label via slot --}}
<x-bt-toggle name="tos">
I accept the <a href="/terms" class="underline text-blue-600">Terms of Service</a>
</x-bt-toggle>
<x-bt-toggle label="Right (default)" />
<x-bt-toggle label="Left side" label-position="left" />
<x-bt-toggle label="Top" label-position="top" />
<x-bt-toggle label="Bottom" label-position="bottom" />
<x-bt-toggle label="Default" /> {{-- beartropy --}}
<x-bt-toggle primary label="Primary" />
<x-bt-toggle blue label="Blue" />
<x-bt-toggle red label="Red" />
All 24 colors + primary: primary, beartropy, red, blue, green, yellow, purple, pink, gray, orange, amber, lime, emerald, teal, cyan, sky, indigo, violet, rose, fuchsia, slate, stone, zinc, neutral.
Colors affect the checked track background, hover state, focus ring, and active state. The thumb is always white.
<x-bt-toggle xs label="Extra Small" />
<x-bt-toggle sm label="Small" />
<x-bt-toggle label="Medium (default)" />
<x-bt-toggle lg label="Large" />
<x-bt-toggle xl label="Extra Large" />
<x-bt-toggle label="Unchecked" />
<x-bt-toggle label="Checked" checked />
<x-bt-toggle label="Disabled off" :disabled="true" />
<x-bt-toggle label="Disabled on" :disabled="true" checked />
Disabled toggles get opacity-60 cursor-not-allowed styling.
{{-- Auto error from $errors bag --}}
<x-bt-toggle wire:model="setting" name="setting" label="Setting" />
{{-- Custom error --}}
<x-bt-toggle label="Accept" :custom-error="'You must accept the terms.'" />
When in error state, the track gets a red ring, the label turns red, and an error message appears below.
<x-bt-toggle label="Notifications" help="You will receive email notifications." />
<x-bt-toggle label="Public profile" hint="Your profile will be visible to everyone." />
help and hint are aliases; help takes precedence.
The toggle has built-in autosave support that calls a Livewire method when toggled:
{{-- Basic autosave --}}
<x-bt-toggle
label="Dark mode"
:autosave="true"
wire:model="darkMode"
/>
{{-- Custom method and debounce --}}
<x-bt-toggle
label="Notifications"
:autosave="true"
autosave-method="savePreference"
:autosave-debounce="500"
wire:model="notifications"
/>
When autosave is enabled:
The autosave calls $wire.call(method, value, key) where:
method defaults to 'savePreference'value is the boolean toggle statekey defaults to the wire:model value, or can be set via autosave-key{{-- Deferred (default) --}}
<x-bt-toggle wire:model="enabled" label="Enabled" />
{{-- Live binding --}}
<x-bt-toggle wire:model.live="darkMode" label="Dark mode" />
When wire:model is present, the Alpine checked state is entangled with the Livewire property via $wire.entangle().
'component_defaults' => [
'toggle' => [
'color' => env('BEARTROPY_UI_TOGGLE_COLOR', 'beartropy'),
'size' => env('BEARTROPY_UI_TOGGLE_SIZE', 'md'),
],
],
All colors include dark mode styles automatically. The unchecked track uses dark:bg-gray-700, labels adapt for dark themes.
How can I help you explore Laravel packages today?