Skip to content
iv-ui v0.3.0

Slider

since 0.1.0

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

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

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>
  • 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.

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>
import { Slider } from '@elluzion/iv-ui';

Props

10 props · 1 events · 0 snippets
PropTypeDefaultDescription
value bindablenumber | [number, number]0Current value, or [start, end] when range is set.
range booleanfalseRenders two handles and a [start, end] value.
min number0Minimum value.
max number100Maximum value.
step number1Increment between values.
tickMarks booleanfalseDraws ticks at every step.
label string''Visible label and accessible name.
disabled booleanfalseDisables interaction and applies the disabled treatment.
showValue booleanfalseShows the current value next to the label.
size 'sm' | 'md''md'Control size.

Events

EventHandler typeDescription
onchange(e: CustomEvent<{ value: number | [number, number] }>) => voidCalled with { value } while the handle moves.

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

KeysAction
Arrow keysChange the value by one step.
Home / EndJump to the minimum or maximum.
TabMoves 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.
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
iv-ui
↑ ↓ navigate ↵ open esc close minisearch · 482 records