Fader

A linear slider for gain and other continuous parameters.

Audio UI

A linear control for continuous parameters such as volume, gain or a send level. The registry component wraps the Fader primitive from @audio-ui/react and adds size variants and thumb marks.

Overview

  • Input: drag the thumb or press the track, or use the mouse wheel or the keyboard. onValueCommitted fires when the interaction ends.
  • Layout: vertical by default, or horizontal, in sm, default and lg sizes.
  • Display: a filled range and a thumb, with optional marks inside the thumb (thumbMarks).
  • Accessibility: the thumb holds a native <input type="range"> that carries the accessible name (aria-label or aria-labelledby), the value text (formatted with format) and the form value (name).

Installation

pnpm dlx shadcn@latest add @audio-ui/fader

Anatomy

Import the primitive and assemble its parts.

import { Fader } from "@audio-ui/react";

<Fader.Root>
  <Fader.Label />
  <Fader.Control>
    <Fader.Track>
      <Fader.Indicator />
    </Fader.Track>
    <Fader.Mark value={50} />
    <Fader.Thumb />
  </Fader.Control>
  <Fader.Value />
</Fader.Root>

Usage

import { Fader } from "@/components/audio-ui/fader";

Uncontrolled: set only the initial value.

<Fader defaultValue={0} max={6} min={-60} step={1} />

Controlled: drive the value from state.

const [gain, setGain] = useState(0);

<Fader
  max={6}
  min={-60}
  onValueChange={setGain}
  onValueCommitted={(value, details) => console.log("Committed:", value, details.reason)}
  step={1}
  value={gain}
/>

Interaction

Pointer

Behavior · 4

Track click / drag
Click or drag on the track to set the value from the pointer position.
Thumb drag
Dragging the thumb changes the value continuously, within min…max.
Commit event
onValueCommitted fires when an interaction ends with a new value.
Lagging value
While dragging, the thumb follows the pointer even if a controlled value updates late; it returns to value on release. Reject a value with eventDetails.cancel().

Keyboard

On the focused thumb:

Keys · 6

ArrowUp / ArrowRight
Increase by step
ArrowDown / ArrowLeft
Decrease by step
PageUp / Shift + ArrowUp
Increase by largeStep (default 10)
PageDown / Shift + ArrowDown
Decrease by largeStep (default 10)
Home
Set to min
End
Set to max

Wheel

The mouse wheel over the fader moves the value by step and reports eventDetails.reason === "wheel".

API reference

Root

Groups all parts of the fader, with audio defaults (vertical, -60…+6) and mouse-wheel stepping. While a pointer drags it, the thumb follows the pointer even if a controlled value lags behind, as with a seek bar driven by playback time or automation. To reject a value, call eventDetails.cancel(). Renders a <div> element.

Props · 8

Data attributes · 2

data-active
Whether the value has reached this mark from the anchor.
data-disabled
Present when disabled.

Control

The interactive area: pointer presses and drags, plus mouse-wheel stepping. Sets touch-action: none so touch drags don't scroll the page. Renders a <div> element.

Data attributes · 2

data-active
Whether the value has reached this mark from the anchor.
data-disabled
Present when disabled.

Indicator

The filled part of the track: from min up to the value, or between the Root's anchor and the value, on whichever side of it the value is. Renders a <div> element.

Data attributes · 2

data-active
Whether the value has reached this mark from the anchor.
data-disabled
Present when disabled.

Mark

A graduation along the track at value: placed from the start of the travel in the fader's direction, where the thumb's center would be at that value. It carries data-active while the value has reached it from the anchor, and data-orientation. Decorative: the thumb's input announces the value. Render your own tick and label inside it. Renders a <div> element.

Props · 1

Data attributes · 2

data-active
Whether the value has reached this mark from the anchor.
data-disabled
Present when disabled.

Registry component

Fader accepts style props (size, thumbMarks, className) plus primitive props from FaderPrimitive.Root.Props (name, form, format, locale, largeStep, render, …). The primitive's Fader.Mark places a graduation at a value along the track, with data-active once the value has reached it, to build your own ruler. aria-label, aria-labelledby, and aria-describedby are forwarded to the thumb's input.

Value and state

Props · 15

Layout and visuals

Props · 4

Additional valid HTML attributes passed to Fader.Root are forwarded.

Examples

Vertical (default)

Audio UI

Horizontal

Audio UI

Pan, filled from the center

anchor={0} makes the fill grow from the center of a -1…1 range, left or right of it.

Audio UI

Mixing console

A fader per channel in dB, from silent at the bottom to +6 dB, beside the meter of what it lets through.

Audio UI

More Shadcn Fader components

Browse 4 production-ready audio/ui Fader components for players, mixers, and synth interfaces. These examples use the headless primitives from @audio-ui/react and stay fully compatible with Shadcn Create so radius, color, and typography match your configured theme.

Browse all 4 Shadcn Fader components for copy-ready layouts, dashboards, and forms built with Tailwind CSS in the audio/ui library.

Built by Ouest Labs, the source code is available on GitHub.
RSS