audiocn-svelte
Esc

Start typing to search the docs

Volume Control

A simple volume slider with a mute button, for players.

1 min read · 166 words

77%

Installation

$ pnpm dlx shadcn-svelte@latest add https://juddisjudd.github.io/audiocn-svelte/r/volume-control.json

Usage

<script lang="ts">
	import { VolumeControl } from "#lib/components/ui/volume-control/index.js";

	let volume = $state(1);
	let muted = $state(false);
</script>

<VolumeControl bind:value={volume} bind:muted />

Unlike the mixer components, the volume here runs from 0 to 1, the same as HTMLMediaElement.volume. The perceptual curve gives the slider more travel at low volumes, where ears are most sensitive. Unmuting at zero restores the last audible volume.

Anatomy

<VolumeControl>
	<VolumeControlMute />
	<VolumeControlSlider />
	<VolumeControlValue />
</VolumeControl>

Examples

In a popover

Theming

The mute button has data-level of muted, low, medium or high, so icons can switch with CSS alone, as in the first example.

API reference

PropTypeDefault
value

0..1. Bindable.

number1
onValueChange (value) => void—
onValueCommit (value) => void—
muted

Bindable.

booleanfalse
onMutedChange (muted) => void—
step

Slider step.

number0.05
curve

How slider position maps to volume.

"linear" | "perceptual""perceptual"
orientation "horizontal" | "vertical""horizontal"
size "sm" | "default" | "lg""default"
disabled booleanfalse
Last updated on October 7, 2026