Skip to content

Loader

final class Phui\Components\Loader

A spinner cycling through chars on an interval, between an optional prefix and postfix. The interval starts on mount and is cleared on unmount, so show and hide the loader by mounting it rather than by toggling a prop. Takes no focus and emits nothing.

A spinner beside the text "Fetching commits..."

php
use Phui\Components\Loader;
use Phui\Nodes\Node;

Node::when($this->loading, Loader::mount()->props(postfix: 'Fetching…'));

Props

PropTypeDefaultDescription
charsstring[]['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']The frames, cycled in order.
intervalint100Milliseconds between frames, read once on mount.
prefixstring|StyledString''Text before the spinner.
postfixstring|StyledString'Loading...'Text after the spinner.

Colours

Phui\Components\Colours\LoaderColours

ColourPalette defaultUsed for
spinneraccentThe spinner frame.
texttextThe prefix and postfix.

Released under the MIT License.