---
title: "Slider"
description: "Selects a number, or a range, along a track."
category: "Form & Input"
slug: slider
url: /components/slider
since: "0.1.0"
status: "stable"
---

# Slider

Selects a number, or a range, along a track.

## Import

```svelte
import { Slider } from '@elluzion/iv-ui';
```

## Preview

A single handle with a visible value.

```svelte
<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>
```

## Usage

- Bind `value`; set `range` for a `[start, end]` tuple.
- `min`, `max`, and `step` define the scale; `tickMarks` sketches it.
- `showValue` prints the current value next to the label.

## Examples

### Range

Two handles bound to a `[start, end]` tuple.

```svelte
<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.

```svelte
<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.

```svelte
<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>
```

### Props

| 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 |
| --- | --- | --- |
| `change` | `(e: CustomEvent<{ value: number \| [number, number] }>) => void` | Called with `{ value }` while the handle moves. |

The legacy `on:name` form is accepted for every event.

### 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`

See the [token reference](/foundations/tokens.md) for values.

### CSS 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`

## 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"` with `aria-valuemin`, `aria-valuemax`, and `aria-valuenow`.
- Range handles are labelled lower and upper; pass `label` to name the scale.
- Values are clamped and snapped to `step` before they are emitted.

## Related

- [Input](/components/input.md)
- [Progress](/components/progress.md)
- [Switch](/components/switch.md)
- [Field](/components/field.md)