Skip to content

Latest commit

 

History

History
59 lines (41 loc) · 964 Bytes

button-group.mdx

File metadata and controls

59 lines (41 loc) · 964 Bytes

Button Group

A set of buttons where clicking one selects it. Functionally equivalent to a Radio field but with a visual button UI.


PHP API

Field::buttonGroup(string $key): ButtonGroupField

Type-specific methods

->options(array $options): static

Associative value => label array.

->allowNull(bool $allow = true): static

Allow deselecting the current value. Default: false.


Storage

Stored as a string (the selected value).

{ "layout_size": "md" }

Example

Field::buttonGroup('layout_size')
    ->label('Size')
    ->options(['sm' => 'S', 'md' => 'M', 'lg' => 'L', 'xl' => 'XL'])
    ->default('md'),

Field::buttonGroup('text_align')
    ->label('Text Alignment')
    ->options(['left' => 'Left', 'center' => 'Center', 'right' => 'Right'])
    ->allowNull(),

Template usage

<div class="size-{{ ctrlfield_get('layout_size') }}">
    ...
</div>