Slider

A control that allows the user to select a value from a range.

Installation

Usage

Example
Source Code
"use client";

import React from "react";
import { Slider } from "@/ui/components/Slider";

function SliderExample() {
  return (
    <Slider
      value={[]}
      onValueChange={(value: number[]) => {}}
      onValueCommit={(value: number[]) => {}}
    />
  );
}

export default SliderExample;

Props

Slider Props
Range Props
Thumb Props
Track Props
Prop
Type
Default value
Notes
value
number[]
The value of the slider.
onValueChange
(value: number[]) => void
Handler called when the value changes.
onValueCommit
(value: number[]) => void
Handler called when the value changes at the end of an interaction.

Examples

Basics

Use defaultValue to set the initial value of the slider (between 0 and 100).

Controlled

Use value and onValueChange props to control the checked state.

Use onValueCommit if you want to update the value only when the user has finished dragging the slider.

Min and max

Use min and max props to set the minimum and maximum values of the slider.

Defining step size

Use step prop to set the step size of the slider.

Adding an input