Slider
Selects a number, or a range, along a track.
import { Slider } from '@elluzion/iv-ui'; 01 Preview
Basic
A single handle with a visible value.
Volume 64
Source· svelte Show Hide
<script lang="ts">
import { Slider } from '@elluzion/iv-ui';
let volume = $state(64);
</script>
<div class="field-row">
<Slider label="Volume" bind:value={volume} showValue />
</div>
<style>
.field-row {
width: 100%;
max-width: 360px;
}
</style>02 Usage
- Bind
value; setrangefor a[start, end]tuple. min,max, andstepdefine the scale;tickMarkssketches it.showValueprints the current value next to the label.
03 Examples
Range
Two handles bound to a [start, end] tuple.
Retention window 20 — 80
20 — 80 days
Source· svelte Show Hide
<script lang="ts">
import { Slider } from '@elluzion/iv-ui';
let window = $state<[number, number]>([20, 80]);
</script>
<div class="field-row">
<Slider label="Retention window" range bind:value={window} showValue />
<p class="readout">{window[0]} — {window[1]} days</p>
</div>
<style>
.field-row {
display: flex;
flex-direction: column;
gap: var(--iv_spacing-sm);
width: 100%;
max-width: 360px;
}
.readout {
margin: 0;
font-family: var(--iv_font-mono);
font-size: var(--iv_text-sm);
color: var(--iv_foreground-dim);
}
</style>Ticks
step and tickMarks expose the increments.
Replicas 3
Source· svelte Show Hide
<script lang="ts">
import { Slider } from '@elluzion/iv-ui';
let replicas = $state(3);
</script>
<div class="field-row">
<Slider label="Replicas" min={1} max={9} step={1} tickMarks bind:value={replicas} showValue />
</div>
<style>
.field-row {
width: 100%;
max-width: 360px;
}
</style>Disabled
The track stays readable but cannot be moved.
Storage quota 70
Source· svelte Show Hide
<script lang="ts">
import { Slider } from '@elluzion/iv-ui';
let quota = $state(70);
</script>
<div class="field-row">
<Slider label="Storage quota" bind:value={quota} showValue disabled />
</div>
<style>
.field-row {
width: 100%;
max-width: 360px;
}
</style>04 API
import { Slider } from '@elluzion/iv-ui';Props
10 props · 1 events · 0 snippets| Prop | Type | Default | Description |
|---|---|---|---|
| value bindable | number | [number, number] | 0 | Current value, or [start, end] when range is set. |
| range | boolean | false | Renders two handles and a [start, end] value. |
| min | number | 0 | Minimum value. |
| max | number | 100 | Maximum value. |
| step | number | 1 | Increment between values. |
| tickMarks | boolean | false | Draws ticks at every step. |
| label | string | '' | Visible label and accessible name. |
| disabled | boolean | false | Disables interaction and applies the disabled treatment. |
| showValue | boolean | false | Shows the current value next to the label. |
| size | 'sm' | 'md' | 'md' | Control size. |
Events
| Event | Handler type | Description |
|---|---|---|
| onchange | (e: CustomEvent<{ value: number | [number, number] }>) => void | Called with { value } while the handle moves. |
The legacy on:name form is accepted for every event.
05 Accessibility
| Keys | Action |
|---|---|
| Arrow keys | Change the value by one step. |
| Home / End | Jump to the minimum or maximum. |
| Tab | Moves between the handles in a range slider. |
- The track exposes
role="slider"witharia-valuemin,aria-valuemax, andaria-valuenow. - Range handles are labelled lower and upper; pass
labelto name the scale. - Values are clamped and snapped to
stepbefore they are emitted.
06 Tokens & CSS hooks
Tokens used
--iv_border --iv_cursor --iv_disabled-opacity --iv_ease-in-out --iv_font-mono --iv_font-ui --iv_foreground --iv_foreground-dim --iv_outline-width --iv_radius-sm --iv_ring --iv_ring-width --iv_slider-track --iv_slider-track-sm --iv_spacing-sm --iv_surface-elevated --iv_text-label --iv_text-sm --iv_thumb-md --iv_transition-base
Class hooks
.iv-active.iv-disabled.iv-fill.iv-header.iv-label.iv-md.iv-root.iv-sm.iv-thumb.iv-tick.iv-ticks.iv-track.iv-value