Forms

Toggle

A button that stays pressed: bold in a text toolbar, a favorite star, a "wrap lines" option. It is a checkbox underneath, styled as a button, so it binds a bool and is sent with forms.

Wrap: true
Blade

A button reading "Wrap lines", with a darker background while on. Clicking it, or Space while it has focus, flips $wrap. While that request runs, a spinner takes the place of the icon and the toggle cannot be flipped again.

Icon only #

A square button with the bold icon. The tooltip is also its accessible name.

Blade

Different icon and text per state #

An outlined star and "Favorite" while off; a filled star and "Favorited" while on.

Blade

Variants and colors #

variant is filled, ghost, subtle or the default outline; color tints the pressed state.

Blade

Sizes and disabled #

size scales the button from xs to 3xl; disabled blocks it.

Blade

With description #

With description or help, the button sits next to the texts; align places it on either side.

Shows more rows on the screen.

Applies to every table.

Tell the team about this change.

Blade

Toolbar from data #

Toggles bound to the same array property each add or remove their own value.

Formats: bold
Blade

Customization #

Classes go to the button; prefixed attributes reach the icons (icon-on:, icon-off:) and the state texts (label-checked:).

Blade

Reference

tk:toggle

Prop Type Default Description
checked bool false Starts on.
icon string null An icon for both states.
iconOn, iconOff string icon The icon while on, and while off.
labelOn, labelOff string null The text while on, and while off.
variant string outline filled, ghost, subtle, or the default outlined button.
color string null A color name for the pressed state (blue...).
tooltip string null A tooltip; with no text in the button, it is the accessible name.
loading bool auto Shows a spinner and blocks the toggle while its request runs. On with wire:model.live or wire:change.
loadingDelay, loadingMinDuration int | string 150, 700 As on tk:switch.
align string left With help or description, where the button sits next to them, as on tk:checkbox.

Also accepts the field props (name, value, size, help...); label is the button text, not a label above it. wire:model and x-model bind a bool, or an array of values when several toggles share the property.

Slots

Slot Description
default The button content, in place of label.

Prefixes

Prefix Goes to
control: The button.
label: The button text, when there is no labelOn/labelOff.
icon-on:, icon-off: The icons.
label-checked:, label-unchecked: The labelOn and labelOff texts.
loading: The spinner.

Customization

Classes go to the button; other attributes to the hidden checkbox. The parts take prefixes (listed in the Reference above).

blade

Accessibility

A native checkbox inside the button, so screen readers announce it as checked or not checked, named by its text or tooltip ("Toggle" when it has neither). With label-on/label-off the state text is hidden from screen readers and the name stays its label, so it does not change with the state. Space flips it; it is reached with Tab. While blocked by a request it has aria-busy and aria-disabled.

Behavior notes

  • Old input from a failed submit restores the state.