Skip to main content
Urbicon UI

Slider

Numeric slider with single and range modes, step snapping, tick marks, and touch support.

Playground

Volume 65
Variant Style variant (tailwind-variants)
Size Style variant (tailwind-variants)
Step
<Slider
  label="Volume"
  showValue
/>

01 Examples

Price filter (range mode)

range binds a [min, max] tuple instead of a single number — two thumbs, one value. Shown here as the product filter it is usually built for.
Price Range $100 – $400
<div class="border-border-subtle bg-surface-elevated w-full space-y-3 rounded-2xl border p-5">
  <Slider
    label="Price Range"
    range
    bind:value={priceRange}
    min={0}
    max={1000}
    step={25}
    showValue
    intent="success"
    formatValue={(v) => {
      if (Array.isArray(v)) return `$${v[0]} – $${v[1]}`;
      return `$${v}`;
    }}
  />
</div>

With Marks

Labelled tick marks for key values along the track. step snaps the thumb to whole increments.
Temperature 22°C
16°20°24°28°30°
<Slider
  label="Temperature"
  bind:value={temperature}
  min={16}
  max={30}
  step={1}
  showValue
  formatValue={(v) => `${v}°C`}
  marks={[
    { value: 16, label: '16°' },
    { value: 20, label: '20°' },
    { value: 24, label: '24°' },
    { value: 28, label: '28°' },
    { value: 30, label: '30°' }
  ]}
/>

Valid & Recommended Range

Three-zone track for domain-specific constraints. validRange is the hard limit (red on violation), recommendedRange the UX recommendation (green), with a warning zone (yellow) in between.
Consumption-based share of heating costs 70 %
Billing-regulation standard (recommended)
Hot water temperature 60 °C
Legionella protection satisfied
Payback period 15 years
Economically viable corridor
<Slider
  label="Consumption-based share of heating costs"
  bind:value={consumptionShare}
  min={0}
  max={100}
  step={5}
  validRange={[50, 100]}
  recommendedRange={[60, 80]}
  showValue
  formatValue={(v) => `${v} %`}
  rangeStatusText={{
    insideRecommended: 'Billing-regulation standard (recommended)',
    insideValidOnly: 'Compliant with the billing regulation, but outside the recommendation',
    outsideValid: 'Billing-regulation violation: at least 50 % must be consumption-based'
  }}
/>
<Slider
  label="Hot water temperature"
  bind:value={waterTemperature}
  min={40}
  max={80}
  step={1}
  validRange={[60, 80]}
  showValue
  formatValue={(v) => `${v} °C`}
  rangeStatusText={{
    insideRecommended: 'Legionella protection satisfied',
    outsideValid: 'Legionella risk: at least 60 °C recommended'
  }}
/>
<Slider
  label="Payback period"
  bind:value={amortYears}
  min={0}
  max={30}
  step={1}
  recommendedRange={[10, 20]}
  outOfValidRangeIntent="warning"
  showValue
  formatValue={(v) => `${v} years`}
  rangeStatusText={{
    insideRecommended: 'Economically viable corridor',
    insideValidOnly: 'Outside the typical corridor'
  }}
/>

Helper & Error

Group-level helper and error text follow the same form-field contract as Input — error overrides helper when both are set.
Brightness 80%
Adjust screen brightness
Budget $0
<Slider
  label="Brightness"
  bind:value={brightness}
  showValue
  formatValue={(v) => `${v}%`}
  helper="Adjust screen brightness"
/>
<Slider
  label="Budget"
  value={0}
  showValue
  formatValue={(v) => `$${v}`}
  error="Please set a budget above $0"
/>

02 Customization

Slot Overrides

track, range, and thumb carry the visual weight (wrapper, label, valueText, mark, and message round out the slot set). A slimmer track with a tinted fill and a larger thumb — pointer, keyboard, and range logic stay untouched.
Opacity 40%
<Slider
  label="Opacity"
  value={40}
  showValue
  formatValue={(v) => `${v}%`}
  slotClasses={{
    track: 'h-1 bg-primary/15',
    range: 'bg-primary',
    thumb: 'size-5 border-2'
  }}
/>

unstyled removes all default classes while role="slider", pointer capture, and keyboard stepping keep working — rebuild track and thumb through slotClasses. A control skin shared across sliders (e.g. a media-player look) belongs in a BlocksProvider preset (presets.Slider) — see Customization.

03 Accessibility

ARIA Slider

Each thumb uses role="slider" with aria-valuemin, aria-valuemax, aria-valuenow, and aria-label. In range mode, thumbs are labelled "minimum" and "maximum" for clear identification.

Keyboard

Arrow Right/Up increases by step, Arrow Left/Down decreases. Page Up/Down moves by 10x step. Home/End jump to min/max.

Touch Support

Uses Pointer Events for unified mouse, touch, and pen support. The touch-none CSS property prevents browser scroll interference during thumb dragging.

Focus & Color

Focus rings use focus-visible: for keyboard-only visibility. Intent colors are paired with shape (filled track vs. outlined thumb) so the control remains usable without color perception.

04 API Reference

29 props
29 props
Prop
Type
Default
Description

05 Types

Local type definitions used by this component.

9 types
Name
Kind
Category
Used by
Description

06 Installation

Import

import { Slider } from '@urbicon-ui/blocks';