Skip to content

Slider

Sliders allow users to adjust a numeric value within a given range.

React

released

Vue

released

Elements

unsupported

Android

unsupported

iOS

unsupported

Examples

Usage

Design Guidelines

See Figma: Warp - Components / Slider

Accessibility

To be accessible, an aria-label prop should be provided to the slider. If the slider is labeled by a separate element, use the labelledby prop with the id of the labeling element instead.

Events

The slider accepts an onChange prop which is triggered whenever the value is changed by the user. Note that this value updates as the user is dragging.

Questions?

Feel free to ask any questions on usage in the Warp DS Slack channel: #nmp-warp-design-system

Frameworks

Import

You can import the component like so:

js
import { Slider } from '@warp-ds/react';

or import it individually to optimize your JS bundle size by adding only the components you need:

js
import { Slider } from '@warp-ds/react/components/slider'

Examples

Enabled

js
function Example() {
  const [value, setValue] = React.useState(2_500_000);

  return (
    <div>
      <output>{value}</output>
      <Slider
        onChange={(value) => setValue(value)}
        value={value}
        min={1000}
        max={10_000_000}
        step={1000}
      />
    </div>
  );
}

Disabled

jsx
<div>
  <Slider aria-label="Disabled slider" value={50} disabled />
</div>

Props

Required props

nametypedefaultnotes

step

number

Specifies the value granularity

value

number

The current value

Optional Props

nametypedefaultnotes

max

number

100

The greatest value in the range of permitted values

min

number

The lowest value in the range of permitted values

disabled

boolean

Whether the slider is disabled

aria-label

number

String value for aria-label

aria-labelledby

string

Identifies the element that labels the slider

aria-valuetext

string

Human readable text alternative for the value

Events

namewhen

onChange

(value: number) => void

Handler that is called when the value of the slider changes