When to use
- A Mac app (Tauri, Electron or a web app that looks native) that changes a level from a shortcut or a media key: volume, display or keyboard brightness, or your own level such as playback speed.
- Feedback for a key held down: every repeat moves the bar without the HUD flickering or re-entering.
- A desktop-style web demo where the overlay should feel like the system's own.
When not to use
- A level people set by dragging: use a slider, which already shows its value.
- Messages and confirmations ("Copied", "Saved"): announce them in a toast or inline status.
- Anything people must act on: the HUD ignores the pointer and leaves after 1.1 seconds. For a reversible action use Undo Pill.
Installation
pnpm dlx shadcn add https://eased.dev/r/mac-hud.jsonnpx shadcn add https://eased.dev/r/mac-hud.jsonyarn dlx shadcn add https://eased.dev/r/mac-hud.jsonbunx --bun shadcn add https://eased.dev/r/mac-hud.jsonThe command adds Mac HUD, everything it builds on and Eased’s tokens to your project.
Install the dependencies
pnpm add motionnpm install motionyarn add motionbun add motionAdd the Eased pieces it builds on
Copy each item’s files the same way, or install them with the CLI:
Copy the source into your project
components/eased/mac-hud/mac-hud.tsxTSX "use client";import { AnimatePresence, motion } from "motion/react";import { useCallback, useEffect, useId, useRef, useState, type ReactNode } from "react";import { MAC_RADIUS, macFont, macMaterial, type MacMaterialMode } from "../lib/mac";import { blur, enter, exit, exitFast, instant, reducedFade, smooth, snappy, swap, swapIn, swapOut, swapShown, useSafeReducedMotion,} from "../lib/motion";export type MacHudKind = "volume" | "brightness" | "keyboard";/** What a HUD can show: a built-in kind, or `custom` with your own `icon` and `label`. */export type MacHudLevel = MacHudKind | "custom";export type MacHudVariant = "classic" | "pill";export type MacHudLabels = { /** Announced before the level, e.g. "Volume 60%". Defaults: "Volume", "Brightness", "Keyboard brightness". */ volume: string; brightness: string; keyboard: string; /** Announced instead of the level while muted: "Volume, muted". Default "muted". */ muted: string;};export type MacHudProps = { /** Show the HUD. Keep it mounted and toggle this so the exit animates; `useMacHud` drives it for you. */ open: boolean; /** Which level it shows; picks the icon and the announcement. `custom` is a level of your own: pass `icon` and `label`. */ kind: MacHudLevel; /** The level, 0 to 1. Shown in quarter segments, the finest step macOS has (⌥⇧ + a media key). */ value: number; /** Volume only: speaker with a slash, empty bar. */ muted?: boolean; /** `custom` only: your glyph (a timer, playback speed), in `currentColor` at the icon's size. It animates its own changes. */ icon?: ReactNode; /** Announced instead of the kind and level, e.g. "Paused, 12 minutes left". Default for `custom`: the level as a percentage. */ label?: string; /** `classic` is the 200×200 square of macOS 15 and earlier; `pill` the top-right capsule of macOS 26. Default "classic". */ variant?: MacHudVariant; /** * `fixed` to the viewport (default), `absolute` in the nearest positioned parent, or `none` * to place it yourself (a Tauri HUD window that is exactly the HUD's size). */ position?: "fixed" | "absolute" | "none"; /** `css` draws the frosted material; `native` leaves it to a window with real vibrancy. Default "css". */ material?: MacMaterialMode; /** * Corner radius, px. Default 18 for classic, a full capsule for pill. In a native window, match * the window's corner: Electron can't round vibrancy, and macOS gives a frameless window ~10. */ radius?: number; /** Called once the exit animation has finished, e.g. to hide a native HUD window. */ onExitComplete?: () => void; labels?: Partial<MacHudLabels>; /** Appended to the HUD's classes; position is kept. */ className?: string;};const DEFAULT_LABELS: MacHudLabels = { volume: "Volume", brightness: "Brightness", keyboard: "Keyboard brightness", muted: "muted",};const SEGMENTS = 16;// Classic sits centred 140px above the bottom edge, as on macOS; in a container shorter than// ~480px that would push it off the top, so it centres vertically instead.const PLACE: Record<MacHudVariant, string> = { classic: "inset-x-0 mx-auto bottom-[max(0px,min(140px,calc(50%-100px)))]", pill: "top-3 right-3",};const POSITION = { fixed: "fixed z-50", absolute: "absolute z-10", none: "relative" } as const;const pct = new Intl.NumberFormat(undefined, { style: "percent", maximumFractionDigits: 0 });const clamp01 = (n: number) => Math.min(1, Math.max(0, n));/** * The macOS volume and brightness overlay: a frosted, click-through HUD that updates in place * while it is up. Not anchored to anything, so it fades and scales in on its own and leaves * faster than it came; a new level never replays the entrance. */export function MacHud({ open, kind, value, muted = false, icon, label, variant = "classic", position = "fixed", material = "css", radius, onExitComplete, labels, className = "",}: MacHudProps) { const reduce = useSafeReducedMotion(); const text = { ...DEFAULT_LABELS, ...labels }; const silent = kind === "volume" && muted; const level = silent ? 0 : clamp01(value); const pill = variant === "pill"; let announce: string; if (label !== undefined) announce = label; else if (kind === "custom") announce = pct.format(level); else if (silent) announce = `${text[kind]}, ${text.muted}`; else announce = `${text[kind]} ${pct.format(clamp01(value))}`; const glyph = (className: string) => kind === "custom" ? ( <span aria-hidden className={`block [&>svg]:size-full ${className}`}> {icon} </span> ) : ( <MacHudIcon kind={kind} value={value} muted={muted} className={className} /> ); return ( <> {/* A live region must exist before its text changes, so it stays mounted outside the HUD. */} <span role="status" className="sr-only"> {open ? announce : ""} </span> {/* Only a real close counts: a variant swap while open also completes an exit. */} <AnimatePresence onExitComplete={open ? undefined : onExitComplete}> {open && ( <motion.div // A new variant is a new HUD: the old one leaves while the new one enters, no morph. key={variant} aria-hidden data-variant={variant} initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.96, y: pill ? -10 : 0 }} animate={{ opacity: 1, scale: 1, y: 0 }} exit={ reduce ? { opacity: 0, transition: reducedFade } : { opacity: 0, scale: 0.98, y: pill ? -6 : 0, transition: exit } } transition={reduce ? reducedFade : { ...snappy, opacity: enter }} style={{ borderRadius: radius ?? (pill ? MAC_RADIUS.pill : MAC_RADIUS.hud) }} className={`pointer-events-none select-none ${POSITION[position]} ${position === "none" ? "" : PLACE[variant]} ${macFont} ${macMaterial("hud", material)} ${ pill ? "flex h-11 w-[200px] items-center gap-3 px-4" : "size-[200px]" } ${className}`} > {pill ? ( <> {glyph("size-5")} <PillBar level={level} reduce={reduce} /> </> ) : ( <> {glyph("absolute inset-x-0 top-11 mx-auto size-20 opacity-70")} <Segments level={level} /> </> )} </motion.div> )} </AnimatePresence> </> );}/** Sixteen 7.5px squares, 2px apart (150px), 40px off the bottom. Each fills in quarters. */function Segments({ level }: { level: number }) { return ( <div className="absolute inset-x-0 bottom-10 mx-auto flex w-[150px] gap-[2px]"> {Array.from({ length: SEGMENTS }, (_, i) => { // Quarter-segment resolution, like macOS. Fill and track never overlap, so the // filled 70% and empty 20% stay exact rather than stacking. const f = clamp01(Math.round((level * SEGMENTS - i) * 4) / 4); return ( <span key={i} className="relative size-[7.5px] shrink-0"> <span className="absolute inset-0 bg-current/20 transition-[clip-path] duration-(--eased-duration-instant) ease-standard reduced:transition-none" style={{ clipPath: `inset(0 0 0 ${f * 100}%)` }} /> <span className="absolute inset-0 bg-current/70 transition-[clip-path] duration-(--eased-duration-instant) ease-standard reduced:transition-none" style={{ clipPath: `inset(0 ${(1 - f) * 100}% 0 0)` }} /> </span> ); })} </div> );}/** A 6px track whose fill slides on `smooth`: a translate, so no layout work per frame. */function PillBar({ level, reduce }: { level: number; reduce: boolean }) { return ( <span className="relative h-1.5 min-w-0 flex-1 bg-current/20 [clip-path:inset(0_round_9999px)]"> <motion.span className="absolute inset-0 rounded-full bg-current/70" initial={false} animate={{ x: `${(level - 1) * 100}%` }} transition={reduce ? instant : smooth} /> </span> );}/* ---------- Icons: filled glyphs in the spirit of SF Symbols, on a 24-unit grid ---------- */const STROKE = 1.8;/** Straight strokes from radius r1 to r2 around (cx, cy), one per angle in degrees (0 = right, 90 = up). */const rays = (cx: number, cy: number, r1: number, r2: number, angles: number[]) => angles .map((a) => { const [c, s] = [Math.cos((a * Math.PI) / 180), -Math.sin((a * Math.PI) / 180)]; const p = (r: number) => `${+(cx + r * c).toFixed(2)} ${+(cy + r * s).toFixed(2)}`; return `M${p(r1)}L${p(r2)}`; }) .join("");/** A wave of radius r around the speaker's mouth, spanning ±deg. */const wave = (r: number, deg: number) => { const [x, y] = [11 + r * Math.cos((deg * Math.PI) / 180), r * Math.sin((deg * Math.PI) / 180)]; return `M${x.toFixed(2)} ${(12 - y).toFixed(2)}A${r} ${r} 0 0 1 ${x.toFixed(2)} ${(12 + y).toFixed(2)}`;};const SPEAKER = "M3 9h3l4.3-3.6c.65-.55 1.7-.08 1.7.77v11.66c0 .85-1.05 1.32-1.7.77L6 15H3a1 1 0 0 1-1-1v-4a1 1 0 0 1 1-1Z";const WAVES = [wave(4, 45), wave(7, 50), wave(10, 52)];const SLASH = "M3.5 3.5 18.5 18.5";// Shift (in grid units) that centres what is drawn: the speaker spans x 2–12, wave n ends at// 11 + r + half a stroke, the slash at 19.4. Three waves are centred as drawn.const CENTRE = [5, 3.05, 1.55, 0];const CENTRE_MUTED = 1.4;const SUN_ALL = [0, 45, 90, 135, 180, 225, 270, 315];const SUN = { min: rays(12, 12, 7, 7.6, SUN_ALL), max: rays(12, 12, 6.9, 9.4, SUN_ALL) };const LIGHT_ALL = [0, 45, 90, 135, 180];const LIGHT = { min: rays(12, 15.2, 7, 7.6, LIGHT_ALL), max: rays(12, 15.2, 6.9, 9.4, LIGHT_ALL) };export type MacHudIconProps = { kind: MacHudKind; /** 0–1. Volume shows 0–3 waves; brightness and keyboard switch to longer rays from half. */ value: number; muted?: boolean; /** Size it here, e.g. `size-5`. Colour is `currentColor`. */ className?: string;};/** * The HUD's glyphs, also handy on your own media keys. Parts that come and go (a wave, the * mute slash, long rays) fade and un-blur on the text-swap tokens; a new kind swaps the whole * glyph with the text-swap rise. */export function MacHudIcon({ kind, value, muted = false, className = "" }: MacHudIconProps) { const reduce = useSafeReducedMotion(); const v = clamp01(value); const waves = v === 0 ? 0 : Math.ceil(v * 3); const bright = v >= 0.5; return ( <span aria-hidden className={`relative block ${className}`}> <AnimatePresence initial={false}> <motion.span key={kind} className="absolute inset-0" initial={reduce ? { opacity: 0 } : swapIn} animate={reduce ? { opacity: 1 } : swapShown} exit={reduce ? { opacity: 0, transition: reducedFade } : { ...swapOut, transition: { ...swap, opacity: exitFast, filter: exitFast } }} transition={reduce ? reducedFade : swap} > {kind === "volume" ? ( // Like separate SF Symbols, each state is centred on its own: the speaker slides // over as waves come and go rather than hanging left of an empty space. <motion.span className="absolute inset-0" initial={false} animate={{ x: `${((muted ? CENTRE_MUTED : CENTRE[waves]) / 24) * 100}%` }} transition={reduce ? instant : snappy} > <Speaker muted={muted} reduce={reduce} /> {WAVES.map((d, i) => ( <Part key={d} shown={!muted && waves > i} reduce={reduce}> <path d={d} fill="none" stroke="currentColor" strokeWidth={STROKE} strokeLinecap="round" /> </Part> ))} <Part shown={muted} reduce={reduce}> <path d={SLASH} fill="none" stroke="currentColor" strokeWidth={STROKE} strokeLinecap="round" /> </Part> </motion.span> ) : ( <> <Part shown reduce={reduce}> {kind === "brightness" ? ( <circle cx="12" cy="12" r="4.4" /> ) : ( <> <path d="M7.2 15.2a4.8 4.8 0 0 1 9.6 0Z" /> <rect x="3" y="17.4" width="18" height={STROKE} rx={STROKE / 2} /> </> )} </Part> {(["min", "max"] as const).map((size) => ( <Part key={size} shown={bright === (size === "max")} reduce={reduce}> <path d={(kind === "brightness" ? SUN : LIGHT)[size]} fill="none" stroke="currentColor" strokeWidth={STROKE} strokeLinecap="round" /> </Part> ))} </> )} </motion.span> </AnimatePresence> </span> );}/** * One layer of a glyph, as its own <svg> so blur works everywhere (Safari ignores CSS * filters on shapes inside an SVG). Always mounted: toggling `shown` cross-fades it. */function Part({ shown, reduce, children }: { shown: boolean; reduce: boolean; children: ReactNode }) { return ( <motion.svg viewBox="0 0 24 24" fill="currentColor" className="absolute inset-0 size-full overflow-visible" initial={false} animate={shown ? (reduce ? { opacity: 1 } : swapShown) : reduce ? { opacity: 0 } : { opacity: 0, filter: `blur(${blur.soft})` }} transition={reduce ? reducedFade : shown ? swap : { ...swap, opacity: exitFast, filter: exitFast }} > {children} </motion.svg> );}/** The speaker, with a gap cut along the mute slash so the slash reads on a filled shape. */function Speaker({ muted, reduce }: { muted: boolean; reduce: boolean }) { const id = `mac-hud-cut-${useId().replace(/[^\w-]/g, "")}`; return ( <svg viewBox="0 0 24 24" fill="currentColor" className="absolute inset-0 size-full overflow-visible"> <mask id={id} maskUnits="userSpaceOnUse" x="0" y="0" width="24" height="24"> <rect width="24" height="24" fill="white" /> <motion.path d={SLASH} fill="none" stroke="black" strokeWidth={STROKE + 3} strokeLinecap="round" initial={false} animate={{ opacity: muted ? 1 : 0 }} transition={reduce ? reducedFade : muted ? swap.opacity : exitFast} /> </mask> <path d={SPEAKER} mask={`url(#${id})`} /> </svg> );}export type MacHudState = { open: boolean; kind: MacHudLevel; value: number; muted: boolean; icon?: ReactNode; label?: string };export type UseMacHudOptions = { /** How long the HUD stays up after the last change, in ms. Default 1100, as on macOS. */ duration?: number;};/** * The HUD's state and its hold timer. `show(kind, value)` opens it, or updates it in place if * it is already up, and restarts the timer; it hides `duration` ms after the last call. * A `custom` level passes its `icon` and `label` here too. Spread `hud` onto `<MacHud>`. */export function useMacHud({ duration = 1100 }: UseMacHudOptions = {}) { const [hud, setHud] = useState<MacHudState>({ open: false, kind: "volume", value: 0, muted: false }); const timer = useRef<number | undefined>(undefined); const hide = useCallback(() => { window.clearTimeout(timer.current); setHud((h) => (h.open ? { ...h, open: false } : h)); }, []); const show = useCallback( (kind: MacHudLevel, value: number, { muted = false, icon, label }: { muted?: boolean; icon?: ReactNode; label?: string } = {}) => { setHud({ open: true, kind, value: clamp01(value), muted, icon, label }); window.clearTimeout(timer.current); timer.current = window.setTimeout(() => setHud((h) => ({ ...h, open: false })), duration); }, [duration], ); useEffect(() => () => window.clearTimeout(timer.current), []); return { hud, show, hide };}Keep the folder layout
The files import each other by relative path (
../lib/motion), so keep each one at the path shown, undercomponents/eased/.
Usage
useMacHud holds the state and the hold timer. Call show(kind, value) on every change and spread hud onto <MacHud>.
import { useEffect, useRef } from "react";import { MacHud, useMacHud } from "@/components/eased/mac-hud/mac-hud";export function Player() { const { hud, show } = useMacHud(); const volume = useRef(0.5); useEffect(() => { const onKey = (e: KeyboardEvent) => { if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return; // One of sixteen segments per press, as on a Mac. const next = Math.round(volume.current * 16) + (e.key === "ArrowUp" ? 1 : -1); volume.current = Math.min(16, Math.max(0, next)) / 16; show("volume", volume.current); }; window.addEventListener("keydown", onKey); return () => window.removeEventListener("keydown", onKey); }, [show]); return <MacHud {...hud} />;}show while the HUD is up updates it in place and restarts the 1.1-second hold, so a held key keeps it on screen until the last repeat.
Examples
Pill
The macOS 26 capsule, 12px in from the top-right corner. Put it under your own menu bar by rendering it in a positioned box that starts below the bar.
<MacHud {...hud} variant="pill" />Muted
Pass muted with the volume: the speaker gets a slash and the bar empties, and the level comes back when you unmute.
show("volume", volume, { muted: true });A level of your own
Pass custom with your own glyph and what to announce. The bar still shows value, and the HUD still updates in place; a glyph that changes (play to pause) animates itself.
show("custom", progress, { icon: <PauseGlyph />, label: "Paused, 12 minutes left" });Inside a container
position="absolute" places it in the nearest positioned parent instead of the viewport. The classic HUD sits 140px above the bottom, or centres in a container too short for that.
<div className="relative h-80"> <MacHud {...hud} position="absolute" /></div>In a desktop window
A HUD floats above every app, so in Tauri or Electron it lives in its own small window that is exactly the HUD's size. In both:
- The window draws real vibrancy, and the HUD takes
material="native"andposition="none". A CSS blur can't see the desktop through a transparent window, so"css"there gives an unblurred tint. - Make the page transparent with
html, body { background: transparent; }(shadcn'sbg-backgroundonbodycovers the vibrancy) and calluseSystemAppearance()from@/components/eased/lib/mac, so the glyphs follow the system's light or dark material. - The window ignores the pointer, never takes focus, and sits centred 140pt above the bottom of the primary display.
- Hide the window in
onExitComplete, or the empty vibrancy stays on screen after the HUD has left. Vibrancy belongs to the window, so it appears and disappears at once while the icon and bar animate.
For the pill, size the window 200×44 and place it 12pt below the menu bar at the right.
In a Tauri app
Checked with Tauri 2.12. The window, in tauri.conf.json. "focusable": false matters: without it show() takes focus, and a tray panel that hides on blur closes. windowEffects only works with transparent: true; macOSPrivateApi is a no-op since 2.12.1.
{ "app": { "windows": [ { "label": "hud", "url": "/hud", "width": 200, "height": 200, "visible": false, "transparent": true, "decorations": false, "focus": false, "focusable": false, "shadow": false, "resizable": false, "alwaysOnTop": true, "skipTaskbar": true, "visibleOnAllWorkspaces": true, "windowEffects": { "effects": ["hudWindow"], "state": "active", "radius": 18 } } ] }}A capability for the window, so its page may move, show, hide and click-through it:
{ "identifier": "hud", "platforms": ["macOS"], "windows": ["hud"], "permissions": [ "core:default", "core:window:allow-show", "core:window:allow-hide", "core:window:allow-set-position", "core:window:allow-set-ignore-cursor-events" ]}The page listens for levels, sent from Rust with app.emit_to("hud", "hud", level) (from a global shortcut handler, say) or from another window with emitTo. It places the window on the primary display each time: the hidden window's own monitor is wherever it was last shown.
import { listen } from "@tauri-apps/api/event";import { PhysicalPosition } from "@tauri-apps/api/dpi";import { getCurrentWindow, primaryMonitor } from "@tauri-apps/api/window";import { useEffect } from "react";import { useSystemAppearance } from "@/components/eased/lib/mac";import { MacHud, useMacHud, type MacHudKind } from "@/components/eased/mac-hud/mac-hud";type Level = { kind: MacHudKind; value: number; muted?: boolean };export function HudWindow() { useSystemAppearance(); const { hud, show } = useMacHud(); useEffect(() => { const win = getCurrentWindow(); win.setIgnoreCursorEvents(true); const off = listen<Level>("hud", async ({ payload }) => { const monitor = await primaryMonitor(); if (monitor) { const size = 200 * monitor.scaleFactor; const x = monitor.position.x + (monitor.size.width - size) / 2; const y = monitor.position.y + monitor.size.height - size - 140 * monitor.scaleFactor; await win.setPosition(new PhysicalPosition(Math.round(x), Math.round(y))); } await win.show(); show(payload.kind, payload.value, { muted: payload.muted }); }); return () => void off.then((unlisten) => unlisten()); }, [show]); return <MacHud {...hud} position="none" material="native" onExitComplete={() => void getCurrentWindow().hide()} />;}In an Electron app
The main process owns the window and sends it each level; showInactive() shows it without taking focus. Electron can't round vibrancy, and macOS gives a frameless window about 10pt corners, so pass radius={10} to match (the pill becomes a rounded rectangle there).
const path = require("node:path");const { app, BrowserWindow, ipcMain, screen } = require("electron");let hud;app.whenReady().then(() => { app.dock?.hide(); // A menu bar app: no Dock icon. hud = new BrowserWindow({ width: 200, height: 200, show: false, frame: false, transparent: true, backgroundColor: "#00000000", focusable: false, hasShadow: false, resizable: false, skipTaskbar: true, vibrancy: "hud", visualEffectState: "active", webPreferences: { preload: path.join(__dirname, "preload.cjs") }, }); hud.setAlwaysOnTop(true, "screen-saver"); hud.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true }); hud.setIgnoreMouseEvents(true); hud.loadFile(path.join(__dirname, "../dist/index.html"), { query: { view: "hud" } });});// Call from a globalShortcut handler, for example.function showHud(level) { const { bounds } = screen.getPrimaryDisplay(); hud.setPosition(Math.round(bounds.x + (bounds.width - 200) / 2), bounds.y + bounds.height - 200 - 140); if (!hud.isVisible()) hud.showInactive(); hud.webContents.send("hud", level);}ipcMain.on("hud-closed", () => hud.hide());const { contextBridge, ipcRenderer } = require("electron");contextBridge.exposeInMainWorld("hud", { onLevel: (callback) => { const listener = (_event, level) => callback(level); ipcRenderer.on("hud", listener); return () => ipcRenderer.off("hud", listener); }, closed: () => ipcRenderer.send("hud-closed"),});import { useEffect } from "react";import { useSystemAppearance } from "@/components/eased/lib/mac";import { MacHud, useMacHud, type MacHudKind } from "@/components/eased/mac-hud/mac-hud";declare global { interface Window { hud: { onLevel: (callback: (level: { kind: MacHudKind; value: number; muted?: boolean }) => void) => () => void; closed: () => void }; }}export function HudWindow() { useSystemAppearance(); const { hud, show } = useMacHud(); useEffect(() => window.hud.onLevel(({ kind, value, muted }) => show(kind, value, { muted })), [show]); return <MacHud {...hud} position="none" material="native" radius={10} onExitComplete={window.hud.closed} />;}API reference
MacHud
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | Show the HUD. Keep it mounted and toggle this so the exit animates; useMacHud drives it. | |
kind | "volume" | "brightness" | "keyboard" | "custom" | Which level it shows: picks the icon and the announcement. custom takes icon and label. | |
value | number | The level, 0 to 1, drawn in quarter segments (macOS's finest step, ⌥⇧ with a media key). | |
muted | boolean | false | Volume only: speaker with a slash, empty bar. |
icon | ReactNode | custom only: your glyph, in currentColor at the icon's size. | |
label | string | Announced instead of the kind and level. Default for custom: the level as a percentage. | |
variant | "classic" | "pill" | "classic" | The 200×200 square of macOS 15 and earlier, or the 200×44 capsule of macOS 26. |
position | "fixed" | "absolute" | "none" | "fixed" | Against the viewport, in the nearest positioned parent, or in flow for you to place (a Tauri HUD window). |
material | "css" | "native" | "css" | native drops the CSS blur and tint for a window that draws real vibrancy. |
radius | number | 18, or a capsule for pill | Corner radius, px. Match a native window's corner: 10 in Electron. |
onExitComplete | () => void | Called when the exit animation has finished (not on a variant swap): hide a native HUD window here. | |
labels | { volume?, brightness?, keyboard?, muted?: string } | "Volume", "Brightness", "Keyboard brightness", "muted" | Translate the announcement. |
className | string | "" | Appended to the HUD's classes; position is kept. |
useMacHud
useMacHud({ duration? }) returns { hud, show, hide }. show(kind, value, { muted?, icon?, label? }) opens or updates the HUD and restarts the hold; hide() closes it at once. duration is the hold after the last show, in ms (default 1100). Spread hud onto <MacHud>.
useSystemAppearance
From @/components/eased/lib/mac. Call it once in a Tauri or Electron HUD window: it puts .dark on <html> while prefers-color-scheme is dark and follows changes, so the glyphs match the native vibrancy. It runs in an effect, so it is safe with server rendering. Eased otherwise follows .dark or data-theme="dark", so a web app keeps its own theme toggle.
MacHudIcon
The HUD's glyphs on their own, for media keys and menus: <MacHudIcon kind="volume" value={1} className="size-4" />. Takes kind, value, muted and className; colour is currentColor.
Accessibility
- A
role="status"live region, mounted before the HUD first shows, announces each change ("Volume 60%", "Volume, muted"), so screen readers hear the level without focus moving. - The visual HUD is
aria-hiddenand ignores the pointer: it never takes focus or blocks a click on what is under it. - It never holds the only copy of information: the level lives in your app, and the HUD only reflects it.
Motion
The HUD fades in on the enter curve while it scales from 0.96 on the snappy spring; the pill also drops 10px. It leaves in 150ms on the ease-in curve to 0.98 (the pill rises 6px), with no overshoot. While it is up, a new value never replays the entrance: classic segments snap in 100ms, the pill's bar slides on the smooth spring, and icon changes (a wave, the mute slash, longer sun rays) fade and un-blur on the text-swap tokens; a new kind swaps the whole glyph. Changing variant while it is up swaps one HUD for the other, without a morph. Reduced motion keeps 100ms opacity fades only and moves the bar at once.
Notes for AI
Use Mac HUD for transient feedback on a level changed by a shortcut or media key in a Mac-style app. Call show from useMacHud on every change, including repeats; render one HUD per window with {...hud} spread onto it. In Tauri or Electron, render it with material="native" and position="none" in a 200×200 vibrancy window that ignores the pointer and can't take focus, with a transparent page and useSystemAppearance(); hide the window in onExitComplete.
Do not unmount it to hide it, do not add a timer of your own (the hook owns the 1.1-second hold), and do not put controls in it: it is click-through. Do not give it a drop shadow, or a different radius except to match a native window's corner (radius={10} in Electron).
Related components
- Undo Toast with Countdown: a transient pill people can act on.
- Animated Segmented Control: the classic and pill switch in the demo.
- Animated Button: the media keys in the demo.