Forms

Slider

Production-quality slider (range input) for selecting numeric values within a given range. Built for mission-critical applications with full WCAG 2.1 AA compliance and WAI-ARIA Slider Pattern support.

Basic Usage

Simple slider with label and value display. Uses native input type='range' for maximum accessibility.

Controls creativity vs. consistency of responses.

With Semantic Labels

Use lowLabel and highLabel to provide meaningful context at the range boundaries instead of raw numbers.

Controls creativity vs. consistency of responses.

With Paired Number Input

Enable showInput for precise value entry. Best practice when users need to type exact values (e.g. 22.5). Slider and input stay in sync.

Custom Format

Use formatValue to display values in a custom format (e.g. speed multiplier with 'x' suffix).

Speaking rate multiplier

Sizes

Choose sm, md (default), or lg based on context and touch targets.

Small

Medium (default)

Large

States

Disabled, error, success, and hint states for form validation.

Disabled

With Error

With Success

With Hint

AI Voice Configuration Example

Real-world example: persona configuration sliders for Synthax voice AI.

Model Parameters

Controls creativity vs. consistency of responses

Speaking rate multiplier

Props

PropTypeDefaultDescription
id stringUnique identifier for the slider
name stringForm field name for form submission
label *stringLabel text for the slider
value number0Current value (bindable)
min number0Minimum value
max number100Maximum value
step number1Step increment
required booleanfalseWhether the field is required
disabled booleanfalseWhether the field is disabled
error stringError message to display
successMessage stringSuccess message when valid (shows green fill)
hint stringHint text below the slider (shows info icon next to label)
description stringDescription text below the label
size 'sm' | 'md' | 'lg''md'Size of the slider
hideLabel booleanfalseHide label visually (still accessible)
class stringAdditional CSS classes for the wrapper
lowLabel stringSemantic label for the low end (e.g. "Consistent")
highLabel stringSemantic label for the high end (e.g. "Creative")
formatValue (value: number) => stringFormat function for displayed value
ariaValueText (value: number) => stringHuman-readable value for screen readers
showInput booleanfalseShow paired number input for precise value entry
alwaysShowFooter booleanfalseAlways render footer to prevent layout shift
validateOnMount booleanfalseShow validation state immediately
onchange (value: number) => voidChange handler
onblur (event: FocusEvent) => voidBlur handler
testId stringTest ID for e2e testing (Playwright, Cypress)

Slider Best Practices

  • Native Input: Uses <input type="range"> for built-in keyboard support (Arrow keys, Home, End).
  • Semantic Labels: Use lowLabel and highLabel when raw numbers aren't meaningful (e.g. "Consistent" / "Creative").
  • Paired Input: Enable showInput when users need precise value entry alongside visual adjustment.
  • ariaValueText: Provide human-readable descriptions for screen readers when formatValue isn't sufficient (e.g. "30 percent").
  • Touch Targets: Thumb is 20px (md) for comfortable touch interaction; use size="lg" for critical controls.
  • Validation: Use validateOnMount when showing validation state before user interaction.

Accessibility

  • WAI-ARIA Slider Pattern: Full aria-valuemin, aria-valuemax, aria-valuenow, aria-valuetext.
  • Keyboard: Arrow keys (step), Home/End (min/max), native focus ring.
  • Reduced Motion: Fill transition disabled for prefers-reduced-motion users.
  • Label Association: Proper for/id and aria-labelledby.
  • Light/Dark Themes: Full support via design tokens; primary-light for fill/thumb/focus in dark mode.

Usage

import { Slider } from '@synthaxai/ui'

// Basic
&lt;Slider label="Temperature" bind:value={temp} min={0} max={1} step={0.05} /&gt;

// With description and semantic labels
&lt;Slider
  label="Temperature"
  bind:value={temp}
  description="Controls creativity vs. consistency of responses."
  lowLabel="Consistent"
  highLabel="Creative"
/&gt;

// With paired number input
&lt;Slider label="Volume" bind:value={vol} min={0} max={100} showInput /&gt;