Fields

Toggle buttons

ToggleButtons shows options as a row of buttons, with colors, icons, grouping and multiple choice.

use Xelqun\Forms\Components\ToggleButtons;

ToggleButtons::make('status')
    ->options(['draft' => 'Draft', 'published' => 'Published'])
    ->colors(['draft' => 'warning', 'published' => 'success'])
    ->icons(['draft' => 'pencil', 'published' => 'check'])
    ->inline();

Join the buttons

grouped() joins them into one compact control.

ToggleButtons::make('size')->options(['s' => 'S', 'm' => 'M', 'l' => 'L'])->grouped();

Choosing several

ToggleButtons::make('days')->multiple()->options($days)->columns(4);

The state is then a list of values.

Yes and no

ToggleButtons::make('feedback')->boolean();

Disabling options

ToggleButtons::make('status')
    ->options($statuses)
    ->disableOptionWhen(fn (string $value): bool => $value === 'archived');