LabDAW

Theme tokens

The color tokens audio/ui adds to the shadcn/ui theme: semantic states, and the audio tokens a skin sets to change the material of a control.

Overview

audio/ui adds semantic color tokens to the shadcn/ui theme, for states such as alerts and badges.

Standard shadcn/ui themes work too. The custom tokens keep contrast consistent across these states.

Extended Tokens

To support advanced state communication, we extend the base palette with additional semantic tokens:

  • --destructive-foreground: Foreground color specifically for destructive actions.
  • --info & --info-foreground: Background and text colors for informational states.
  • --success & --success-foreground: Background and text colors for success/positive outcomes.
  • --warning & --warning-foreground: Background and text colors for cautionary states.
  • --invert & --invert-foreground: Background and text colors for invert states.
app/globals.css
@theme inline {
  --color-destructive-foreground: var(--destructive-foreground);
  --color-info: var(--info);
  --color-info-foreground: var(--info-foreground);
  --color-success: var(--success);
  --color-success-foreground: var(--success-foreground);
  --color-warning: var(--warning);
  --color-warning-foreground: var(--warning-foreground);
  --color-invert: var(--invert);
  --color-invert-foreground: var(--invert-foreground);
}

:root {
  --destructive-foreground: var(--color-red-800);
  --info: var(--color-violet-500);
  --info-foreground: var(--color-violet-900);
  --success: var(--color-emerald-500);
  --success-foreground: var(--color-emerald-900);
  --warning: var(--color-yellow-500);
  --warning-foreground: var(--color-yellow-900);
  --invert: var(--color-zinc-900);
  --invert-foreground: var(--color-zinc-50);
}

.dark {
  --destructive-foreground: var(--color-red-600);
  --info: var(--color-violet-500);
  --info-foreground: var(--color-violet-600);
  --success: var(--color-emerald-500);
  --success-foreground: var(--color-emerald-600);
  --warning: var(--color-yellow-500);
  --warning-foreground: var(--color-yellow-600);
  --invert: var(--color-zinc-700);
  --invert-foreground: var(--color-zinc-50);
}

Audio Tokens

The knob, the fader and the meter take their colors from audio tokens, each named after the material it paints. None is defined by default: each falls back to the shadcn token it replaces, so an install looks the same until a token is set.

TokenMaterialPaintsDefault
--audio-socketThe ring a knob turns inKnob control--secondary
--audio-capWhat the hand holdsKnob body, fader thumb--card
--audio-grooveThe slot a value runs inFader track, meter channel--input
--audio-accentThe valueKnob arc and indicator, fader range and thumb mark, an active tick--primary
--audio-printScales printed on the panelTicks, scale labels, meter marks--muted-foreground
--audio-readoutA value shown on demandValue chips, the active scale label, the meter's peak--foreground
--audio-readout-inkThe text on a readoutValue chips--background
--audio-levelA signal in rangeMeter fill--success
--audio-warnA signal near its limitMeter fill--warning
--audio-clipA signal over its limitMeter fill--destructive

Set them on any element to restyle what it holds, in both color schemes:

app/globals.css
.hardware {
  --audio-socket: oklch(0.9 0.01 85);
  --audio-cap: oklch(0.97 0.01 85);
  --audio-groove: oklch(0.32 0.01 85);
  --audio-accent: oklch(0.66 0.2 40);
  --audio-print: oklch(0.45 0.01 85);
}

A token changes a color, never a behavior: the controls keep their keyboard, pointer and ARIA whatever they wear.

Skins

A skin is tokens and materials, drawn on the elements' own parts: the knob, the fader, the meter, the XY pad, the envelope, the pads, the piano and the device panels. It changes how a control looks, never its props, events or ARIA, and it is one sheet: React, Vue, Svelte and plain HTML read the same rules, so a skin looks the same in each.

Put the skin's class on the element that holds the controls, with audio-body for its surface:

import { Knob } from "@/components/audio-ui/knob"

<div className="skin-hardware audio-body rounded-2xl p-8">
  <Knob aria-label="Drive" defaultValue={30} />
</div>

In React, <Install name="skin-hardware" /> writes the skin into your Tailwind stylesheet. In every framework, the CLI writes it as its plain sheet, css/skin-hardware.css, last in the index the app imports once:

pnpm dlx @audio-ui/cli add knob skin-hardware

Both sheets are served at https://www.audio-ui.dev/css/skins/ for a project that copies them by hand.

Axes

A skin derives its audio tokens from a few axes. Set them on the skin's own element, with style or a selector more specific than the skin's class.

AxisWhat it setsDefault
--audio-shadeThe material. Every token follows from it, and a dark shade, of a lightness under 0.5, turns the skin darkThe skin's own, one for each color scheme
--audio-accentThe valueThe skin's own, one for each color scheme
--audio-inkThe lettering and the printed scalesDerived from the shade
--audio-depthHow far a part stands out of the surface or sinks into it. 0 is flat1
--audio-roundnessThe corners the skin draws. 0 is square, 2 twice as round1
<div
  className="skin-hardware audio-body rounded-2xl p-8"
  style={{ "--audio-shade": "oklch(0.55 0.08 60)", "--audio-accent": "oklch(0.8 0.15 90)" }}
>
  <Knob aria-label="Drive" defaultValue={30} />
</div>

The tokens are derived with relative colors (oklch(from var(--audio-shade) …)), which browsers support since 2024.

Hardware

The Hardware skin is a matte body, dark inset screens, one accent and printed scales.

pnpm dlx shadcn@latest add @audio-ui/skin-hardware
ElementDrawn as
KnobA matte cap lit from above in a dark socket, a needle in the lettering's color, its arc in the accent, and a printed scale of eleven ticks when it has no marks
FaderA narrow slot with no range, and a ribbed cap whose middle rib is in the accent
MeterIts level lit in segments, as a row of lamps, in the screen's ink, warning and clipping colors
XY pad, envelopeScreens set in the body: their grid, curve and cursor in the screen's ink and the accent
PadsCaps to strike, lit from above, flashing in the accent
PianoIvory and ebony keys in the body, held in the accent
Device panelsTheir frame takes the body, their graphs become screens

Neu

The Neu skin is one material lit from above: a knob is a dome pushed out of the surface, a pad is pushed up and pressed in while struck, a fader's groove, a meter's channel, the XY pad, the envelope and the keyboard are pressed into it, a device panel is a plate with its graphs sunk in.

pnpm dlx shadcn@latest add @audio-ui/skin-neu

Its shadows are the material multiplied by itself and its light the material screened with itself, so a warm shade casts warm shadows. --audio-depth sets how far the parts stand out.

Device panels

A device panel inside a skin wears it as it is: its frame takes the body, its graphs and pads change with the theme's colors the skin sets. The panels themselves do not change. --audio-grid is the width of a column of a panel with no groups, 4.5rem by default. For faces of your own, give DeviceFacesProvider from @/components/audio-ui/device-faces a Knob or a Fader with the element's props.

Materials

ClassMaterial
audio-bodyThe matte panel
audio-screenA dark screen set into the body
audio-capWhat the hand holds, lit from above
audio-grooveThe slot a value runs in
audio-printLettering printed on the body
audio-lamp, audio-lamp-onA lamp, off and lit

The skin adds three tokens to the audio tokens: --audio-body, --audio-screen and --audio-screen-ink. Each material takes its light from the skin: --audio-body-shadow, --audio-screen-shadow, --audio-cap-image, --audio-cap-shadow and --audio-groove-shadow.

For general customization guidelines such as adding your own custom colors or switching between utility classes and variables, please refer to the official shadcn/ui documentation.

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