Skip to Content

Slider

An input where the user selects a value or a range between a minimum and maximum.

import { Slider } from "@dapplelight/signet-ui/components/slider"

export function Demo() {
  return (
    <Slider defaultValue={[50]} max={100} step={1} aria-label="Volume" className="max-w-sm" />
  )
}

Installation

npm i @dapplelight/signet-ui

Usage

import { Slider } from "@dapplelight/signet-ui/components/slider"

<Slider defaultValue={[50]} max={100} step={1} aria-label="Volume" />

Examples

Range

import { Slider } from "@dapplelight/signet-ui/components/slider"

export function Demo() {
  return (
    <Slider defaultValue={[20, 80]} max={100} step={5} className="max-w-sm" />
  )
}

Controlled

Monthly budget$2500
import { useState } from "react"
import { Slider } from "@dapplelight/signet-ui/components/slider"

export function Demo() {
  const [budget, setBudget] = useState([2500])
  return (
    <div className="w-full max-w-sm space-y-3">
      <div className="flex justify-between text-sm">
        <span>Monthly budget</span>
        <span className="font-mono">${budget[0]}</span>
      </div>
      <Slider
        value={budget}
        onValueChange={(v) => setBudget(v as number[])}
        min={500}
        max={5000}
        step={100}
        aria-label="Monthly budget"
      />
    </div>
  )
}

Vertical

import { Slider } from "@dapplelight/signet-ui/components/slider"

export function Demo() {
  return (
    <div className="h-40">
      <Slider defaultValue={[60]} orientation="vertical" aria-label="Level" />
    </div>
  )
}

Disabled

import { Slider } from "@dapplelight/signet-ui/components/slider"

export function Demo() {
  return (
    <Slider defaultValue={[40]} disabled aria-label="Brightness" className="max-w-sm" />
  )
}

API Reference

PropTypeDefaultDescription
defaultValuenumber[]noneInitial values, one entry per thumb. Pass an array even for one thumb: the thumb count comes from the array, and without value or defaultValue two thumbs render.
valuenumber[]-Controlled value.
onValueChange(value: number[], details) => void-Called as the value changes.
onValueCommitted(value: number[], details) => void-Called when a drag, key press or track press ends.
minnumber0Lowest value.
maxnumber100Highest value.
stepnumber1Increment.
largeStepnumber10Increment for Page Up, Page Down and Shift + arrow.
minStepsBetweenValuesnumber0Least number of steps between range thumbs.
thumbCollisionBehavior"push" | "swap" | "none""push"What colliding range thumbs do.
thumbAlignment"center" | "edge" | "edge-client-only""edge"Signet sets edge so a thumb at min or max stays inside the track.
namestring-Form field name.
orientation"horizontal" | "vertical""horizontal"Direction of the slider.
disabledbooleanfalseBlocks interaction.
aria-labelstring-Name for the thumb. Applied only when there is a single thumb; aria-labelledby works the same way.

The remaining props come from the Base UI slider root. For a range slider, name each thumb yourself: only a single-thumb slider gets aria-label.