Skip to content

Button ​

final class Phui\Components\Button

A label inside a rounded border. Takes focus and emits press when activated; while disabled it drops out of focus traversal and ignores both key and mouse presses.

Three buttons: focused, at rest and disabled

php
use Phui\Components\Button;

Button::mount()
    ->props(label: 'Save', disabled: $this->saving)
    ->on('press', fn () => $this->save());

Props ​

PropTypeDefaultDescription
labelstring|StyledString'Submit'The text inside the border.
disabledboolfalseGreys the button out and stops it emitting.
borderChars?BorderCharSetnullThe border to draw. Defaults to BorderCharSet::rounded().

Emits ​

EventPayloadEmitted when
pressnullThe button is activated and is not disabled.

Input ​

InputAction
Enter SpacePress
Left clickPress

Colours ​

Phui\Components\Colours\ButtonColours

ColourPalette defaultUsed for
texttextThe label at rest.
textFocusedaccentThe label while focused.
textDisabledmutedThe label while disabled.
bordermutedThe border at rest.
borderFocusedaccentThe border while focused.
borderDisabledmutedThe border while disabled.

Released under the MIT License.