Skip to content
HHydro UIdocs
Navigate
ComponentsSlider
ImplementedForms / range input

Slider

Choose a bounded numeric value along a visual range.

Interactive

Try it

value, min, max, step, orientation, disabled
Live previewReady
MarkupStateEvents
<hui-slider id="playground-slider" name="volume" min="0" max="100" step="5" value="40">
  <hui-slider-range></hui-slider-range>
  <hui-slider-thumb aria-label="Volume"></hui-slider-thumb>
</hui-slider>
data-state
Waiting for enhancement

No component events yet.

Usage

Use hui-slider when a user benefits from choosing a value along a bounded visual range. Use a number field when exact text entry is the primary task. This implementation supports one thumb; do not model multi-thumb ranges with duplicate slider roots.

Anatomy

  • Root and track: hui-slider
  • Thumb control: hui-slider-thumb with role="slider"
  • Optional fill: hui-slider-range
  • Form integration: visually hidden native input owned by the root

Examples

Fixture exampleSource-backed
<section aria-labelledby="slider-heading">
    <h2 id="slider-heading">Volume</h2>
    <form id="slider-form">
      <hui-slider id="volume-slider" name="volume" min="0" max="100" step="5" value="40" aria-labelledby="slider-heading">
        <hui-slider-range></hui-slider-range>
        <hui-slider-thumb><b>Volume</b></hui-slider-thumb>
      </hui-slider>
      <hui-slider id="vertical-slider" name="balance" min="0" max="100" step="5" value="40" orientation="vertical" aria-label="Balance">
        <hui-slider-range></hui-slider-range>
        <hui-slider-thumb></hui-slider-thumb>
      </hui-slider>
      <hui-slider id="disabled-slider" name="disabled-volume" min="0" max="100" step="5" value="40" disabled aria-label="Disabled volume">
        <hui-slider-range></hui-slider-range>
        <hui-slider-thumb></hui-slider-thumb>
      </hui-slider>
    </form>
  </section>

API reference

AttributeMeaning
valueNormalized committed numeric value.
min, max, stepNumeric bounds and step grid; defaults are 0, 100, and 1.
large-stepPageUp/PageDown multiplier.
orientationhorizontal (default) or vertical.
dirDirection used for horizontal keyboard behavior.
disabledDisables the thumb and native form value.
name, form, requiredHidden native form input metadata.
aria-label, aria-labelledby, aria-describedbyAccessible naming and description for the thumb.
value-textOptional formatted accessible value.

The root emits hui-value-change with { value }. Arrow keys change by step, PageUp/PageDown use large-step, Home/End commit the bounds, and pointer dragging updates the value. The root exposes data-state="active", data-disabled, --hui-position-pct, and the thumb exposes data-state="dragging". Values are clamped, step-aligned, and serialized without trailing zeroes. SSR emits resolved slider ARIA attributes and a hidden form input; without JavaScript, the native input remains available while pointer and keyboard enhancement are unavailable.

States and styling

StateContract and styling guidance
DefaultEnabled thumb exposes the normalized value and remains in the tab order.
HoverUse --hui-color-interactive-hover for thumb feedback.
Activedata-state="dragging" exposes pointer interaction; keep the interactive fill visible.
FocusKeep a visible ring with --hui-color-focus-ring and --hui-size-focus-ring.
DisabledExpose aria-disabled, remove the thumb from the tab order, and use disabled aliases.
ErrorNo built-in validation state; pair aria-invalid="true" with an associated message and --hui-color-danger.
State channel

Attributes are the source of truth. Style derived state with data-state, ARIA attributes, and the --hui-* token aliases.

Accessibility and keyboard support

The slider exposes a labelled slider control. Arrow keys change by step, Home and End commit the bounds, and the focus ring must remain visible.

SSR and forms

Slider preserves source-of-truth attributes and accessible state in server-rendered light-DOM markup. Use stable IDs when the component generates relationships; client enhancement adds interaction without changing the public contract.

Code

<form>
  <hui-slider id="volume" name="volume" min="0" max="100" step="5" value="40">
    <hui-slider-range></hui-slider-range>
    <hui-slider-thumb aria-label="Volume"></hui-slider-thumb>
  </hui-slider>
</form>
<hui-slider id="playground-slider" name="volume" min="0" max="100" step="5" value="40">
  <hui-slider-range></hui-slider-range>
  <hui-slider-thumb aria-label="Volume"></hui-slider-thumb>
</hui-slider>