VolumeControl

A speaker button and a volume track. Dragging or arrow keys set the level, the icon follows it, and the button mutes and brings the old level back. Media.

Open playground

About

VolumeControl is a React component in the Media category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { VolumeControl } from "@ashutoshswamy/smoui" and set value, onMuteChange.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { VolumeControl } from "@ashutoshswamy/smoui";

<VolumeControl defaultValue={0.6} onChange={(v) => (audio.volume = v)} onMuteChange={(m) => (audio.muted = m)} />

Props 2

value / defaultValue / onChange

Level from 0 to 1.

number
onMuteChange

Fires when the mute button flips.

(muted: boolean) => void