Skip to content

Checkbox

final class Phui\Components\Checkbox

A bracketed marker followed by a label, bound to a boolean. Takes focus.

Two checkboxes, the focused one checked

php
use Phui\Components\Checkbox;
use Phui\Events\EmitEvent;

Checkbox::mount()
    ->props(label: 'Ready to ship', checked: $this->ready)
    ->on('change', fn (EmitEvent $e) => $this->ready = $e->data);

Props

PropTypeDefaultDescription
labelstring|StyledString''The text after the box.
checkedCharstring'✓'The marker shown when checked.
uncheckedCharstring' 'The marker shown when unchecked.

Models

The component holds this and emits on every change. Pass it as a prop to take ownership, and handle its emit — see binding a value both ways.

ModelTypeDefaultEmits
checkedboolfalsechange

Emits

EventPayloadEmitted when
changeboolThe box is toggled.

Input

InputAction
Enter SpaceToggle
Left clickToggle

Colours

Phui\Components\Colours\CheckboxColours

ColourPalette defaultUsed for
bracketmutedThe [ and ] at rest.
bracketFocusedaccentThe [ and ] while focused.
markermutedThe marker while unchecked.
markerCheckedaccentThe marker while checked.

Released under the MIT License.