Back to Shark UI

Slider

docs/components/slider

latest7.3 KB
Original Source

Sections

Components

Utilities

Forms

Hooks

Slider

Copy Markdown

A slider for selecting a value from a range.

DocsAPI

PreviewCode

Installation#

CLIManual

pnpmbunnpmyarn

pnpm dlx shadcn@latest add @shark/slider

Usage#

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

Controlled#

Control the value with value and onValueChange for a controlled slider.

PreviewCode

Greater than 80

Temperature40

Examples#

With label and value#

Use <Field>, <SliderLabel>, and <SliderValue> for accessible labelling and to show the current value.

PreviewCode

Opacity50

Range#

Use an array with two values for a range slider.

PreviewCode

Vertical#

Use orientation="vertical" for a vertical slider.

PreviewCode

Disabled#

Use the disabled prop to disable the slider.

PreviewCode

Min and max#

Set min and max to constrain the slider's value range.

PreviewCode

Volume50

Marks#

The showMarkers and markerInterval props display markers and control the interval between them.

PreviewCode

0123456789101112

Step#

Set step to control the slider's granularity.

Use with showMarkers and markerLabels to show custom labels on the markers.

PreviewCode

Storage size

5GB25GB50GB

Marks are only supported for horizontal sliders.

API Reference#

Slider#

Root component. Manages value, track, range, and thumb(s).

PropTypeDefault
valuenumber[]-
defaultValuenumber[]-
onValueChange(details: ValueChangeDetails) => void-
minnumber0
maxnumber100
stepnumber1
orientation`"horizontal""vertical"`
disabledbooleanfalse
showMarkersbooleanfalse
markerIntervalnumber1
markerLabelsstring[][]
classNamestring-

SliderLabel#

Label for the slider. Required for accessibility.

PropTypeDefault
classNamestring-

SliderValue#

Shows the current value. Useful for numeric display or formatting.

PropTypeDefault
classNamestring-

For a complete list of props, see the Ark UI documentation.

[

Previous page

Skip Nav ](/docs/components/skip-nav)[

Next page

Spinner ](/docs/components/spinner)

On This Page

InstallationUsageControlledExamplesWith label and valueRangeVerticalDisabledMin and maxMarksStepAPI ReferenceSliderSliderLabelSliderValue