Castle logo

CASTLE UI

Search

K

The Slider is used to allow users to make selections from a range of values.

Castle UI exports 5 components for Slider:

  • Slider: The wrapper that provides context and functionality for all children.
  • SliderTrack: The empty part of the slider that shows the track.
  • SliderFilledTrack: The filled part of the slider.
  • SliderThumb: The handle that's used to change the slider value.
  • SliderMark: The label or mark that shows names for specific slider value

Usage

Import

import {
Slider,
SliderTrack,
SliderFilledTrack,
SliderThumb,
SliderMark,
} from '@passfort/castle'

Copy

Example

Note: We recommend adding a aria-label or aria-labelledby prop to provide an accessible label for the Slider.

Copy

live example

Discrete Sliders

Discrete sliders allow you to snap to predefined sets of values. This can be accomplished using the step prop.

Copy

live example

Getting the final value when dragging the slider

Dragging the slider can trigger lots of updates and the user might only be interested in the final result after sliding is complete. You can use onChangeEnd for this.

Copy

live example

Changing the slider orientation

Copy

live example

Contents