slider

The Slider component allows users to select a value from a range.

Usage

Default

50

const [value, setValue] = useState(50);
<Slider
  min={0}
  max={100}
  step={1}
  value={value}
  onChange={(e) => setValue(Number(e.target.value))}
/>

Props

Data table
TypeDescription
aria-describedbystringId of external element(s) that describe the slider.
aria-invalidboolean | "true" | "false"Marks the slider as invalid.
aria-labelstringAccessible label for the slider if no visible label is provided.
aria-labelledbystringId of external element(s) that label the slider.
aria-orientation"horizontal" | "vertical"Orientation of the slider.
aria-requiredboolean | "true" | "false"Marks the slider as required for assistive technology.
aria-valuemaxnumberExplicit maximum value for assistive technology.
aria-valueminnumberExplicit minimum value for assistive technology.
aria-valuenownumberExplicit current numeric value for assistive technology.
aria-valuetextstringHuman-friendly text alternative for the current value.
classNamestringAdditional CSS class names for custom styling.
data-testidstringOptional test ID for testing frameworks.
disabledbooleanIf true, the slider is disabled and cannot be interacted with.
idstringOptional id for the slider input.
labelstringOptional label displayed above or beside the slider.
maxnumberThe maximum value of the slider.
minnumberThe minimum value of the slider.
namestringOptional form field name.
onChange(e: React.ChangeEvent<HTMLInputElement>) => voidCallback invoked when the slider value changes. Receives the change event from the input element.
onValueChange((value: number) => void)Callback invoked when the slider value changes.
requiredbooleanIf true, the slider is required in form contexts.
roundingRoundingTypeControls the rounding of the component. One of: "none" | "small" | "medium" | "large" | "full"
shadowShadowTypeControls the shadow of the component. One of: "none" | "light" | "medium" | "strong" | "intense"
showValuebooleanIf true, the current slider value is displayed alongside the slider.
sizeSizeTypeSize variant for the slider. One of: "xs" | "small" | "medium" | "large" | "xl"
stateStateTypeState of the slider. One of: "success" | "error" | "warning" | "disabled" | ""
stepnumberIncrement step for the slider.
themeThemeTypeTheme variant for styling. One of: "primary" | "secondary" | "tertiary" | "quaternary" | "clear"
valuenumberThe current numeric value of the slider.