Skip to main content

Starwind UI v3.0 beta is now available! Read the migration guide

Installation

Framework Availability

Astro Available React Available

Slider is available for Astro and React.

Usage

General Notes

The Slider component provides an accessible way to select values within a range. It supports:

  • Single value selection: Default mode with one thumb
  • Range selection: Pass an array to defaultValue for two thumbs
  • Keyboard navigation: Arrow keys, Page Up/Down, Home/End
  • Form integration: Works with native form submission via hidden inputs

Range Slider

Pass an array of two values to create a range slider with two thumbs.

With Step

Use the step prop to control the increment value.

Variants

The slider supports multiple color variants.

Disabled

Vertical Orientation

Set orientation="vertical" for a vertical slider. Make sure to provide a container with a defined height.

Form Submission

The slider includes hidden <input type="range"> elements for native form submission. For range sliders, the inputs are named with array notation (e.g., price[0], price[1]).

Submit the form to see values

API Reference

Styled Component API

These props are added or materially changed by the installed Astro styled component. Standard HTML attributes remain available through the inherited interfaces noted below. Follow the Primitive and Runtime links for lower-level behavior props.

Slider

Inherits div attributes. Omits `defaultValue`, `onChange`, and `value`.

Contains the following additional props:

Prop Type Default Toggle details
defaultValue number | number[] 0
Description
Sets the initial value when the component is uncontrolled.
Classification
Primitive override
Primitive prop
slider.Root.defaultValue
orientation "horizontal" | "vertical" "horizontal"
Description
Selects the horizontal or vertical layout direction.
Classification
Primitive override
Primitive prop
slider.Root.orientation
value number | number[]
Description
Controls or identifies the component value.
Classification
Primitive override
Primitive prop
slider.Root.value
variant "default" | "primary" | "secondary" | "info" | "success" | "warning" | "error" "default"
Description
Selects the component's visual variant.
Classification
Styled variant

Primitive And Runtime API

Use these references when you need the lower-level behavior APIs behind Slider.

Primitive API

Runtime API

Slider primitive
createSlider from @starwind-ui/runtime/slider

Changelog

v2.0.0

  • Rebuilt Slider on Starwind Runtime for values, keyboard interaction, dragging, and native form participation.
  • See the Slider Primitive for the underlying unstyled anatomy and behavior API.

v1.0.2

  • Refactor tailwind variants functions into separate variants.ts file

v1.0.0

  • Initial release with starwind v1.13.0