Fader
A slider-style fader component for audio mixing interfaces. Supports vertical and horizontal orientations, size variants, and customisable thumb marks.
A drag-to-adjust fader built entirely from plain HTML elements and Tailwind — no external slider primitives. Ideal for volume controls, mixing boards, or any parameter you want to expose in a tactile, studio-style UI. Supports vertical and horizontal orientations, three size variants, and configurable thumb marks.
Loading...
<script lang="ts">
import { Fader } from "$lib/components/ui/audio/elements/fader/index.js";
let value = $state(50);
</script>
<div class="h-48">
<Fader {value} onValueChange={(e) => (value = e)} />
</div> Installation
Copy and paste the following code into your project.
Usage
<script lang="ts">
import { Fader } from "$lib/components/ui/audio/elements/fader/index.js";
let value = $state(50);
</script> <Fader {value} onValueChange={(e) => (value = e)} /> Horizontal Fader
Loading...
<script lang="ts">
import { Fader } from "$lib/components/ui/audio/elements/fader/index.js";
let value = $state(50);
</script>
<div class="flex w-full max-w-sm flex-col items-center gap-4">
<Fader orientation="horizontal" {value} onValueChange={(e) => (value = e)} />
<span class="text-muted-foreground text-sm tabular-nums">{value}</span>
</div> Custom Thumb Marks
Loading...
<script lang="ts">
import { Fader } from "$lib/components/ui/audio/elements/fader/index.js";
let value = $state(50);
</script>
<div class="flex h-48 items-center justify-center gap-8">
<Fader thumbMarks={1} {value} onValueChange={(e) => (value = e)} label="1" />
<Fader thumbMarks={3} onValueChange={(e) => (value = e)} {value} label="3" />
<Fader thumbMarks={5} onValueChange={(e) => (value = e)} {value} label="5" />
</div> No Thumb Marks
Loading...
<script lang="ts">
import { Fader } from "$lib/components/ui/audio/elements/fader/index.js";
let value = $state(50);
</script>
<div class="flex h-48 items-center justify-center">
<Fader thumbMarks={false} {value} onValueChange={(e) => (value = e)} />
</div> API Reference
Fader
Props
Behavior
- Interaction is handled by an invisible native
<input type="range">stretched over the full component — keyboard and pointer events just work, fully accessible. - Vertical mode uses
writing-mode: vertical-lr+direction: rtlon the hidden input so dragging upward increases the value, matching physical fader muscle memory. - The fill and thumb position are driven by derived state — no manual DOM manipulation needed.
Tip: Use
bind:valuefor two-way binding in Svelte, or passvalue+onValueChangefor a controlled setup.
Examples
Volume Control
Wire directly to audioStore for a store-driven volume fader:
Loading...
<script lang="ts">
import { Fader } from "$lib/components/ui/audio/elements/fader/index.js";
import { audioStore } from "$lib/audio-store.svelte.js";
function handleVolumeChange(value: number) {
audioStore.setVolume({ volume: value / 100 });
}
</script>
<div class="flex h-48 items-center justify-center gap-4">
<Fader
label="Vol"
value={audioStore.volume * 100}
onValueChange={handleVolumeChange}
/>
</div> Multiple Faders (Mixing Board)
Loading...
<script lang="ts">
import { Fader } from "$lib/components/ui/audio/elements/fader/index.js";
let channels = $state([
{ label: "Kick", value: 75 },
{ label: "Snare", value: 60 },
{ label: "Bass", value: 80 },
{ label: "Vox", value: 90 },
{ label: "FX", value: 40 }
]);
</script>
<div class="flex h-56 items-end justify-center gap-4">
{#each channels as channel (channel.label)}
<div class="flex flex-col items-center gap-2">
<Fader
value={channel.value}
label={channel.label}
size="sm"
onValueChange={(e) => (channel.value = e)}
/>
<span class="text-muted-foreground text-xs tabular-nums"
>{channel.value}</span
>
</div>
{/each}
</div> Related
- Audio Player — player controls to pair with faders
- Audio Provider — audio context and state management