Slider

Slider is a component used for allowing users to select a value from a range.

Usage

import { Slider } from "@yamada-ui/react"
<Slider.Root>
  <Slider.Track>
    <Slider.Range />
    <Slider.Thumb />
  </Slider.Track>
  <Slider.Marks />
</Slider.Root>

Change Variant

Change Size

Change Color Scheme

Set Default Value

To set a default value, set a number to defaultValue.

Set Minimum and Maximum Values

To set minimum and maximum values, set a number to min or max.

Enable Range Selection

To enable range selection, set an array to defaultValue or value.

Set Minimum Distance

To set the minimum distance between thumbs, set a number to betweenThumbs.

Change Orientation

To change the orientation, set orientation to "horizontal" or "vertical". The default is "horizontal".

Use Marks

To use marks, set an array to marks.

Change Shape

Disable

To disable the slider, set disabled to true.

Read-Only

To make read-only, set readOnly to true.

Display Tooltips

Handle Start and End Events

To handle start and end events, use onChangeStart or onChangeEnd.

Value: 50, Start Value: 50, End Value: 50

Set Step Value

To set a step value, set a number to step.

Customize Styling

Control

Props

Accessibility

The Slider follows the WAI-ARIA - Slider Pattern for accessibility.

Keyboard Navigation

KeyDescriptionState
ArrowRightIncreases the value based on the step value.-
ArrowLeftDecreases the value based on the step value.-
ArrowUpIncreases the value based on the step value.-
ArrowDownDecreases the value based on the step value.-
HomeSets the value to min.-
EndSets the value to max.-
PageUpIncreases the value based on the min and max values.-
PageDownDecreases the value based on the min and max values.-

ARIA Roles and Attributes

ComponentRoles and AttributesUsage
Slider.Thumbrole="slider"Indicates that this is a slider.
aria-labelSets "Slider thumb".
aria-labelledbySets the id of the related Slider.Root.
aria-orientationSets "horizontal" or "vertical" based on the orientation value. Default is "horizontal".
aria-valueminSets the min value. Default is 0.
aria-valuemaxSets the max value. Default is 100.
aria-valuenowSets the current value.
aria-valuetextSets the current value.
aria-describedbyIf Slider.Root is within a Field.Root and Field.Root has an errorMessage, helperMessage, or a Field.ErrorMessage, Field.HelperMessage, sets its id.
aria-readonlySet to "true" if readOnly is set.
aria-disabledSet to "true" if disabled is set.
aria-invalidSet to "true" if invalid is set.
aria-requiredSet to "true" if required is set.
Slider.Markaria-hiddenExcludes the element from the accessibility tree.
role="presentation"Indicates that this is a presentation.
SliderInputaria-hiddenExcludes the element from the accessibility tree.
aria-describedbyIf Slider.Root is within a Field.Root and Field.Root has an errorMessage, helperMessage, or a Field.ErrorMessage, Field.HelperMessage, sets its id.
aria-readonlySet to "true" if readOnly is set.
aria-disabledSet to "true" if disabled is set.
aria-invalidSet to "true" if invalid is set.
aria-requiredSet to "true" if required is set.