For the complete documentation index, see llms.txt. Markdown variants are available by appending .md to any URL or sending an Accept: text/markdown header. An agent skill is available at /.well-known/agent-skills/site-skill.md.
119

Slider

An input where the user selects a value from within a given range.

import { Slider } from "@/components/ui/slider";

export function SliderDemo() {
  return (
    <Slider
      defaultValue={[75]}

Installation

$ pnpm dlx shadcn@latest add https://shadcn-cssinjs.com/r/slider.json

Usage

import { Slider } from "@/components/ui/slider";
<Slider defaultValue={[33]} max={100} step={1} />

Range

Use an array with two values for a range slider.

import { Slider } from "@/components/ui/slider";

export function SliderRange() {
  return (
    <Slider
      defaultValue={[25, 50]}

Multiple Thumbs

Use an array with multiple values for multiple thumbs.

import { Slider } from "@/components/ui/slider";

export function SliderMultiple() {
  return (
    <Slider
      defaultValue={[10, 20, 70]}

Vertical

Use orientation="vertical" for a vertical slider.

import { Slider } from "@/components/ui/slider";

export function SliderVertical() {
  return (
    <div className="mx-auto flex w-full max-w-xs items-center justify-center gap-6">
      <Slider

Controlled

0.3, 0.7
"use client";

import * as React from "react";

import { Label } from "@/components/ui/label";
import { Slider } from "@/components/ui/slider";

Disabled

Use the disabled prop to disable the slider.

import { Slider } from "@/components/ui/slider";

export function SliderDisabled() {
  return (
    <Slider
      defaultValue={[50]}

RTL

To enable RTL support in shadcn/ui, see the RTL configuration guide.

"use client";

import * as React from "react";

import { useTranslation } from "@/components/language-selector";
import type { Translations } from "@/components/language-selector";

API Reference

See the Base UI Slider documentation.