OneScript

Slider

Select a value from a continuous range.

A controlled slider. Pass the current value and update it from onChange.

import { Slider, useState } from "onescript/views"

function VolumeSlider() {
  const [volume, setVolume] = useState(50)
  return (
    <Slider
      value={volume}
      onChange={setVolume}
      min={0}
      max={100}
      step={1}
    >
      Volume
    </Slider>
  )
}
PropTypeDescription
valuenumberCurrent value.
onChange(value: number) => voidRuns while the user drags the slider.
minnumberLower bound. Defaults to 0.
maxnumberUpper bound. Defaults to 1. Must be greater than min.
stepnumberOptional positive step. Without it the value is continuous.
minimumValueLabelViewChildView shown at the minimum end of the track.
maximumValueLabelViewChildView shown at the maximum end of the track.
onEditingChanged(editing: boolean) => voidReceives true when the user starts dragging and false when they release.
childrenViewChildThe label. Most styles only use it for accessibility.
import { Slider, Symbol } from "onescript/views"

<Slider
  value={brightness}
  onChange={setBrightness}
  minimumValueLabel={<Symbol name="sun.min" />}
  maximumValueLabel={<Symbol name="sun.max.fill" />}
  onEditingChanged={editing => setDragging(editing)}
>
  Brightness
</Slider>

Also accepts Modifiers. It is only available in App and Action view sessions; widgets reject it with an unsupported view type error.

How is this guide?

Last updated on