Audio UI
A numeric field for an audio parameter: a tempo, a gain, a transpose, a cutoff, a pan, a velocity. It reads as a DAW's does, the name at its start, the value in monospace figures, the unit after it, and every way in a DAW to change it.
Overview
- Typing: type a value and press Enter, or leave the field. What is typed stays in the field until it is committed, so a half-typed number never reaches
onValueChange. - Stepping: the arrow keys step by
step, with Shift bylargeStepand with Alt bysmallStep; the Page keys bylargeStep; Home and End go tominandmax.steppersadds a minus and a plus either side. The wheel never changes the value. - Scrubbing: drag the label or the unit sideways (
scrub="horizontal", right is more) or up and down ("vertical", up is more), one step everyscrubSensitivitypixels; hold Shift for large steps, Alt for small ones. The pointer is hidden while it drags, so it can go on past the screen's edge. - Display:
precisiondigits after the point (as many asstephas by default, or asformatsays when it is given), andformatfor the rest, such as a sign (signDisplay) or a percent. Figures are not grouped (1200 Hz, not 1,200 Hz) unlessformatsays so.
Installation
pnpm dlx shadcn@latest add @audio-ui/parameter-field
Usage
import { ParameterField } from "@/components/audio-ui/parameter-field";Uncontrolled: set only the initial value.
<ParameterField defaultValue={-6} label="Gain" max={24} min={-36} precision={1} step={0.1} unit="dB" />Controlled: drive the value from state, and close an undo step when a gesture ends.
const [bpm, setBpm] = useState(120);
<ParameterField
label="Tempo"
max={999}
min={20}
onValueChange={setBpm}
onValueCommitted={commitTempo}
precision={2}
steppers
unit="BPM"
value={bpm}
/>Dense: size="sm" for a panel of many, and hideLabel where the label sits elsewhere; the label still names the field.
<ParameterField hideLabel label="Transpose" scrub="vertical" size="sm" unit="st" />Text of its own: formatValue and parseValue write the value as text and read typed text back, such as a position in bars.beats.16ths, with the same look, keys and scrubbing. shortLabel shows a shorter word than the accessible name.
<ParameterField
formatValue={(seconds) => formatBars(seconds, meter, "position")}
label="Clip start"
onValueChange={setStart}
parseValue={(text) => parseBars(text, meter, "position")}
shortLabel="Start"
size="sm"
step={sixteenth}
value={start}
/>API reference
Props · 19
hideLabel: drag it to scrub.format, as many as it says unless precision is given too.precision: a sign, a percent, grouping (off by default).false for no scrubbing.decrement and increment, with icons in place of the minus and the plus, as a zoom's magnifiers.format, precision and steppers are left aside. null keeps the value as it was.More Shadcn Parameter field components
Browse 2 production-ready audio/ui Parameter field 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 2 Shadcn Parameter field components for copy-ready layouts, dashboards, and forms built with Tailwind CSS in the audio/ui library.