Skip to content

Slider ​

final class Phui\Components\Slider

A track filled up to value, growing to the width available to it. Steps are clamped to min and max, so the value never leaves the range. Takes focus.

A slider labelled Volume, filled to 70

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

Slider::mount()
    ->props(min: 0, max: 100, step: 5, value: $this->volume)
    ->on('change', fn (EmitEvent $e) => $this->volume = $e->data);

Props ​

PropTypeDefaultDescription
minint0Lowest value the track represents.
maxint10Highest value the track represents.
stepint1How far one keypress or scroll notch moves the value.
fillCharstring'━'Repeated up to the thumb.
emptyCharstring'─'Repeated after the thumb.
leftBracketCharstring''Drawn before the track. Omitted while empty.
rightBracketCharstring''Drawn after the track. Omitted while empty.

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
valueint0change

Emits ​

EventPayloadEmitted when
changeintThe value moves.

Input ​

InputAction
← ↓ h jDecrease by step
→ ↑ l kIncrease by step
Scroll wheelIncrease scrolling up, decrease scrolling down

Colours ​

Phui\Components\Colours\SliderColours

ColourPalette defaultUsed for
fillmutedThe filled part of the track at rest.
fillFocusedaccentThe filled part, and the brackets, while focused.
emptysurfaceThe remainder of the track.

Released under the MIT License.