Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Buttons

  • Button
  • ShimmerButton
  • InteractiveHoverButton
  • RainbowButton
  • PulsatingButton
  • RippleButton
  • ButtonGroup
  • SocialButton

Basic Inputs

  • Input
  • Textarea
  • CellEditor
  • Select
  • Checkbox
  • CheckboxGroup
  • Radio
  • Switch
  • Toggle
  • Segmented
  • Slider
  • NumberField
  • ElasticSlider

Advanced Inputs

  • MathTextarea
  • QuestionEditor
  • QuestionAnswer
  • MathField
  • SecretField
  • PasswordGenerator
  • Combobox
  • RemoteSelect
  • Listbox
  • Mentions
  • InputOTP
  • Rating
  • Upload
  • RegionSelect
  • ImageCropper
  • ScopeMatrix
  • Transfer
  • Cascader
  • TreeSelect
  • RegionCascader
  • CountrySelect
  • MarkdownEditor
  • Novel editor
  • RichTextEditor
  • CodeEditor
  • IssueReporter
  • ColorPicker
  • ColorField
  • ColorSwatchPicker
  • Choicebox
  • EmojiPicker
  • VoiceRecord
  • IconPicker
  • InspectorPanel

Date and Time

  • Calendar
  • DatePicker
  • DateTimePicker
  • DateRangePicker
  • TimePicker
  • TimeField

Form Frameworks

  • Form
  • ModalForm / DrawerForm
  • ProForm
  • StepsForm
  • LoginForm
  • AuthPanel
  • ClickCaptcha
  • Label
  • Field
  • SearchForm

Slider

slider

Selects a numeric value or range along a keyboard-accessible track.

Usage

Basic usage

defaultValue Set the initial value and drag the slider to take the value.

tsx
<Slider defaultValue={40} className="w-64" />

Display value

showValue Reads the current value above the track.

60
tsx
<Slider defaultValue={60} showValue className="w-64" />

Interval selection

defaultValue The passed array automatically becomes a double slider interval selection.

25 – 75
tsx
<Slider defaultValue={[25, 75]} showValue className="w-64" />

Stepper

step controls the minimum step size, here each step is 10.

50
tsx
<Slider defaultValue={50} step={10} showValue className="w-64" />

Disabled

disabled Lock the slider and reduce the overall transparency.

tsx
<Slider defaultValue={40} disabled className="w-64" />

When to use

Use Slider when users should drag to choose a value or range, such as volume, price, or percentage, and approximate magnitude matters more than exact entry. Use NumberField for precise numbers with step buttons, or Segmented for a small discrete set.

Import

ts
import { Slider } from "@hulianui/ui"

Props

Accepts Base UI Slider.Root props except render and children. A numeric value creates a single thumb; an array creates a range automatically.

NameTypeDefaultDescription
valuenumber|readonly number[]-Controlled value; an array represents a range.
defaultValuenumber|readonly number[]-Initial value when uncontrolled.
minnumber0minimum value
maxnumber100maximum value
stepnumber1step amount
disabledbooleanfalseDisable
showValuebooleanfalseShows the current Slider.Value above the track.
thumbAriaLabelstring | [string, string]-Accessible name for the thumb. Falls back to the Root aria-label; pass a two-item tuple to name each thumb of a range separately.
classNamestring-Root wrapper className
The remaining props of Base UI Slider.Root (name, orientation, etc.) are transparently transmitted as they are.

Events

Common Base UI Slider.Root events are passed through with their upstream signatures.

EventTypeDescription
onValueChange(value: number|number[], eventDetails) => voidValue change callback (pass number for single value, number[] for range)
onValueCommitted(value: number|number[], eventDetails) => voidCallback when dragging ends/submits

Example

tsx
<Slider defaultValue={60} showValue className="w-64" />

Range:

tsx
<Slider defaultValue={[25, 75]} showValue className="w-64" />

Usage guidelines

  • Pass a number for one thumb and number[] for a range; there is no separate range prop.
  • Set showValue to display the numeric readout; it is hidden by default.
  • className applies to the Root wrapper. Supply a width such as w-64, or the slider may collapse to its content width.
  • aria-label lands somewhere else than you wrote it: on a single-value slider it moves to the thumb (the visually hidden <input type="range">) instead of staying on the Root. The Root is a role="group", and a name there leaves screen readers announcing just “slider, 100” once focus reaches the control. Since the group holds exactly one control this is a move rather than a copy: duplicating the name would have it announced twice and would make name-based queries such as getByLabelText match two elements. A range keeps the group name; use thumbAriaLabel with a two-item tuple there, or both thumbs sound identical.

Related

Input · Textarea · Select · Checkbox · CheckboxGroup · Radio

Playground

40
<Slider defaultValue={40} min={0} max={100} step={1} showValue />
PreviousSegmentedFormsNextNumberField

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Events
    • Example
    • Usage guidelines
    • Related
  • Playground