Skip to content

Alert ​

final class Phui\Components\Alert

An icon and a message, both in the colour of the alert's severity. Fills the width available to it. Takes no focus and emits nothing.

Four alerts stacked, one of each severity

php
use Phui\Components\Alert;

Alert::mount()->props(
    type: Alert::ERROR,
    message: 'Could not write to disk.',
);

Props ​

PropTypeDefaultDescription
typestringAlert::INFOWhich severity to render.
messagestring|StyledString''The text beside the icon.
infoCharstring'i'Icon for Alert::INFO.
successCharstring'✓'Icon for Alert::SUCCESS.
warningCharstring'!'Icon for Alert::WARNING.
errorCharstring'✕'Icon for Alert::ERROR.

Constants ​

ConstantValue
Alert::INFO'info'
Alert::SUCCESS'success'
Alert::WARNING'warning'
Alert::ERROR'error'

An unrecognised type falls back to the info icon and colour.

Colours ​

Phui\Components\Colours\AlertColours

ColourPalette defaultUsed for
infoinfoIcon and message when type is info.
successsuccessIcon and message when type is success.
warningwarningIcon and message when type is warning.
errordangerIcon and message when type is error.

Released under the MIT License.