Radio Tuner
A car-stereo style tuner. The left half is the edge of a large wheel whose centre sits behind the readout, so the ticks curve away from you. Drag it up or down to tune, flick it and it coasts to a stop on a step, scroll over it with a trackpad, or tap any number to jump straight there. The inner ring is FM, the outer ring is AM, and pressing on either one switches to that band. Use Full screen to see it at a real display size.
A fisheye dial
The ticks aren't spaced evenly. Each frequency's distance from the needle goes
through a soft fisheye, θ = u / (1 + |u| / 80°), so the dial is magnified
where you're tuning and compressed toward the top and bottom. Turning it, the
numbers spread apart as they approach the needle and bunch up as they leave,
which reads as a curved surface without any 3D. Labels are rotated to follow
the wheel, and every mark fades out toward the edges.
The loupe
Over the needle sits a lens. It covers the FM ring and redraws it at 3.4× with
a tick every 0.2 MHz, so a single 0.1 MHz step is a visible move, and the
needle lands between two ticks when you're off the grid. The rest of the dial
is a normal SVG; the loupe is one clipPath and a second pass of ticks.
Two bands, one wheel
FM (87.5–108 MHz, 0.1 steps) and AM (530–1700 kHz, 10 kHz steps) each keep
their own frequency, so switching bands and back returns to where you were.
The ring you aren't using dims, and its marker drops to grey. The readout pads
to a fixed width (098.8, 0640) and dims the padding zeros, so the digits
never jump around.
Motion
- Drag maps vertical movement to frequency at the needle's scale, so the tick under your finger stays under your finger.
- Flick hands the release velocity to an inertia animation whose target is snapped to the nearest step, so it always coasts to a real frequency.
- Tap inverts the fisheye to find the frequency under the pointer, then springs there.
- Scroll moves the dial directly and settles on a step 120ms after the wheel stops.
Every one of these is interruptible: grabbing the dial mid-coast stops it where it is. With reduced motion, the dial jumps instead of gliding.
Status
The ring beside the clock fills with signal strength, which rises as you get near a station. Within one step of a station its name appears above the readout. REC toggles a recording state, and the clock is the visitor's local time, rendered only on the client so it never mismatches the server.
Keyboard
The dial is a vertical slider. Arrow keys move one step, Shift + arrows seek
to the next station, Page Up and Page Down move ten steps, and Home and End go
to the ends of the band. The value text reads the frequency and station name.
Usage
The dial is neutral by default; pass accent for the markers and active band,
or set --radio-accent from a class to give light and dark different shades.
<RadioTuner
accent="oklch(0.77 0.16 70)"
defaultBand="FM"
defaultFrequency={{ FM: 98.8, AM: 1010 }}
stations={[
{ band: "FM", frequency: 98.8, name: "KISS 98.8 FM" },
{ band: "AM", frequency: 1010, name: "NEWS 1010 AM" },
]}
onTune={(band, frequency) => console.log(band, frequency)}
/>
"use client";
import {
animate,
motion,
useMotionValue,
useMotionValueEvent,
useReducedMotion,
type AnimationPlaybackControls,
type MotionValue,
} from "motion/react";
import { useEffect, useId, useRef, useState, useSyncExternalStore } from "react";
import { cn } from "@/lib/utils";
export type Band = "FM" | "AM";
export type Station = {
band: Band;
/** MHz for FM, kHz for AM. */
frequency: number;
name: string;
};
type BandSpec = {
min: number;
max: number;
step: number;
/** Degrees of dial per unit at the needle, before the fisheye. */
deg: number;
/** Radius (viewBox units) the drag speed is measured at. */
radius: number;
decimals: number;
/** Integer digits on the readout; missing ones are dimmed zeros. */
intDigits: number;
unit: string;
spokenUnit: string;
/** How far from a station the signal still reaches. */
reach: number;
};
const BANDS: Record<Band, BandSpec> = {
FM: {
min: 87.5,
max: 108,
step: 0.1,
deg: 5.2,
radius: 870,
decimals: 1,
intDigits: 3,
unit: "MHz",
spokenUnit: "megahertz",
reach: 0.4,
},
AM: {
min: 530,
max: 1700,
step: 10,
deg: 0.045,
radius: 690,
decimals: 0,
intDigits: 4,
unit: "kHz",
spokenUnit: "kilohertz",
reach: 40,
},
};
const DEFAULT_STATIONS: Station[] = [
{ band: "FM", frequency: 88.5, name: "JAZZ 88.5 FM" },
{ band: "FM", frequency: 91.3, name: "CLASSIC 91.3" },
{ band: "FM", frequency: 94.7, name: "WAVE 94.7 FM" },
{ band: "FM", frequency: 98.8, name: "KISS 98.8 FM" },
{ band: "FM", frequency: 101.1, name: "NOVA 101.1" },
{ band: "FM", frequency: 104.3, name: "METRO 104.3" },
{ band: "FM", frequency: 107.5, name: "PULSE 107.5" },
{ band: "AM", frequency: 640, name: "TALK 640 AM" },
{ band: "AM", frequency: 880, name: "SPORTS 880" },
{ band: "AM", frequency: 1010, name: "NEWS 1010 AM" },
{ band: "AM", frequency: 1240, name: "OLDIES 1240" },
{ band: "AM", frequency: 1530, name: "WEATHER 1530" },
];
// The dial is the left edge of a large wheel whose centre sits off to the
// right, behind the readout. Everything below is in viewBox units.
const VB_W = 1280;
const VB_H = 878;
const CX = 1150;
const CY = 439;
/** Fisheye strength: the dial is magnified at the needle and compressed toward the edges. */
const FISHEYE = 80;
/** Angles past this are off the screen. */
const VISIBLE = 40;
const R_LABEL = 985;
const R_FM = [815, 915] as const;
const R_FINE = [766, 780] as const;
const R_AM = [660, 715] as const;
/** Pointer presses inside this radius grab the AM ring. */
const R_SPLIT = 740;
const LOUPE = { inner: 770, outer: 945, angle: 5.6, corner: 16, zoom: 3.4 };
const SPRING = { type: "spring", stiffness: 420, damping: 42, mass: 0.6 } as const;
const clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));
function snap(v: number, spec: BandSpec) {
const stepped = Math.round(v / spec.step) * spec.step;
return Number(clamp(stepped, spec.min, spec.max).toFixed(spec.decimals));
}
/** Units from the needle → degrees on the dial. */
function warp(delta: number, deg: number) {
const u = delta * deg;
return u / (1 + Math.abs(u) / FISHEYE);
}
/** Degrees on the dial → units from the needle. */
function unwarp(theta: number, deg: number) {
const t = Math.min(Math.abs(theta), FISHEYE * 0.9);
return (Math.sign(theta) * (t / (1 - t / FISHEYE))) / deg;
}
function polar(r: number, theta: number) {
const a = (theta * Math.PI) / 180;
return [CX - r * Math.cos(a), CY - r * Math.sin(a)] as const;
}
/** Every multiple of `every` that is on the band and on screen. */
function marks(value: number, spec: BandSpec, every: number, range = VISIBLE) {
const reach = unwarp(range, spec.deg);
const lo = Math.ceil(Math.max(spec.min, value - reach) / every - 1e-9);
const hi = Math.floor(Math.min(spec.max, value + reach) / every + 1e-9);
const out: { f: number; theta: number }[] = [];
for (let i = lo; i <= hi; i++) {
const f = i * every;
out.push({ f, theta: warp(f - value, spec.deg) });
}
return out;
}
/** Fades marks toward the top and bottom edges. */
const edge = (theta: number) => Math.max(0, 1 - (Math.abs(theta) / VISIBLE) ** 2 * 0.8);
function loupePath() {
const { inner: r1, outer: r2, angle: a, corner: c } = LOUPE;
const d1 = (c / r1) * (180 / Math.PI);
const d2 = (c / r2) * (180 / Math.PI);
const p = (r: number, t: number) => polar(r, t).map((n) => n.toFixed(2)).join(" ");
return [
`M ${p(r2, a - d2)}`,
`A ${r2} ${r2} 0 0 0 ${p(r2, -a + d2)}`,
`Q ${p(r2, -a)} ${p(r2 - c, -a)}`,
`L ${p(r1 + c, -a)}`,
`Q ${p(r1, -a)} ${p(r1, -a + d1)}`,
`A ${r1} ${r1} 0 0 1 ${p(r1, a - d1)}`,
`Q ${p(r1, a)} ${p(r1 + c, a)}`,
`L ${p(r2 - c, a)}`,
`Q ${p(r2, a)} ${p(r2, a - d2)}`,
"Z",
].join(" ");
}
const LOUPE_PATH = loupePath();
function Tick({
r,
theta,
width,
opacity,
}: {
r: readonly [number, number];
theta: number;
width: number;
opacity: number;
}) {
const [x1, y1] = polar(r[0], theta);
const [x2, y2] = polar(r[1], theta);
return (
<line
x1={x1}
y1={y1}
x2={x2}
y2={y2}
stroke="currentColor"
strokeWidth={width}
strokeOpacity={opacity}
strokeLinecap="round"
/>
);
}
function Dial({ fm, am, band, clipId }: { fm: number; am: number; band: Band; clipId: string }) {
const fmSpec = BANDS.FM;
const amSpec = BANDS.AM;
const fmDim = band === "FM" ? 1 : 0.45;
const amDim = band === "AM" ? 1 : 0.45;
return (
<svg
aria-hidden
viewBox={`0 0 ${VB_W} ${VB_H}`}
className="pointer-events-none absolute inset-0 size-full"
>
<defs>
<clipPath id={clipId}>
<path d={LOUPE_PATH} />
</clipPath>
</defs>
{/* FM ring: a long tick every 0.5 MHz, whole numbers a little brighter. */}
{marks(fm, fmSpec, 0.5).map(({ f, theta }) => (
<Tick
key={`fm-${f}`}
r={R_FM}
theta={theta}
width={3}
opacity={(Number.isInteger(f) ? 0.42 : 0.28) * edge(theta) * fmDim}
/>
))}
{/* FM numbers every 2 MHz, turned to follow the wheel. */}
{marks(fm, fmSpec, 2).map(({ f, theta }) => {
const [x, y] = polar(R_LABEL, theta);
const near = clamp(1 - (Math.abs(theta) - 4) / 8, 0, 1);
return (
<text
key={`label-${f}`}
x={x}
y={y}
transform={`rotate(${theta.toFixed(3)} ${x.toFixed(2)} ${y.toFixed(2)})`}
textAnchor="middle"
dominantBaseline="central"
fill="currentColor"
fillOpacity={(0.38 + 0.62 * near) * edge(theta) * fmDim}
fontSize={30}
className="tabular-nums"
>
{f}
</text>
);
})}
{/* The loupe covers the FM ring at the needle and redraws it magnified. */}
<path
d={LOUPE_PATH}
className="fill-card"
stroke="currentColor"
strokeOpacity={0.22}
strokeWidth={2}
/>
<g clipPath={`url(#${clipId})`}>
{marks(fm, fmSpec, 0.2, LOUPE.angle / LOUPE.zoom + 2).map(({ f, theta }) => (
<Tick
key={`zoom-${f.toFixed(1)}`}
r={[832, 905]}
theta={theta * LOUPE.zoom}
width={3.5}
opacity={0.5 * fmDim}
/>
))}
<line
x1={CX - 905}
x2={CX - 828}
y1={CY}
y2={CY}
stroke="currentColor"
strokeOpacity={fmDim}
strokeWidth={4}
strokeLinecap="round"
/>
</g>
{/* Fine ring: one dot per 0.1 MHz. */}
{marks(fm, fmSpec, 0.1).map(({ f, theta }) => (
<Tick
key={`fine-${f.toFixed(1)}`}
r={R_FINE}
theta={theta}
width={2}
opacity={0.3 * edge(theta) * fmDim}
/>
))}
{/* AM ring: a tick every 50 kHz, turning on its own. */}
{marks(am, amSpec, 50).map(({ f, theta }) => (
<Tick
key={`am-${f}`}
r={R_AM}
theta={theta}
width={3}
opacity={(f % 250 === 0 ? 0.42 : 0.26) * edge(theta) * amDim}
/>
))}
{/* FM marker: arrow and accent line, left of the loupe. */}
<g
className={band === "FM" ? "stroke-(--radio-accent)" : "stroke-current opacity-30"}
strokeWidth={2.5}
>
<path d={`M 95 ${CY - 6} L 104 ${CY} L 95 ${CY + 6} Z`} className="fill-current stroke-none" />
<line x1={128} x2={196} y1={CY} y2={CY} />
</g>
{/* AM marker: arrow, label, and accent dash beside the AM ring. */}
<g className={band === "AM" ? "stroke-(--radio-accent)" : "stroke-current opacity-30"} strokeWidth={2.5}>
<line x1={354} x2={372} y1={CY} y2={CY} />
<path d={`M 406 ${CY - 6} L 397 ${CY} L 406 ${CY + 6} Z`} className="fill-current stroke-none" />
<text
x={460}
y={CY}
textAnchor="middle"
dominantBaseline="central"
fontSize={18}
className="fill-current stroke-none"
>
AM
</text>
<line x1={510} x2={522} y1={CY} y2={CY} />
</g>
</svg>
);
}
function Readout({ value, spec }: { value: number; spec: BandSpec }) {
const [int, dec] = value.toFixed(spec.decimals).split(".");
const padded = int.padStart(spec.intDigits, "0");
const lead = padded.length - int.length;
const chars = (padded + (dec ? `.${dec}` : "")).split("");
return (
<span className="tabular-nums">
{chars.map((c, i) => (
<span key={i} className={i < lead ? "text-foreground/30" : undefined}>
{c}
</span>
))}
</span>
);
}
/** Ring that fills with signal strength. */
function Signal({ strength }: { strength: number }) {
const r = 15;
const c = 2 * Math.PI * r;
const filled = 0.08 + 0.92 * strength;
return (
<svg viewBox="0 0 40 40" aria-hidden className="size-[3.2cqw] -rotate-90">
<circle cx={20} cy={20} r={r} fill="none" stroke="currentColor" strokeOpacity={0.22} strokeWidth={7} />
<circle
cx={20}
cy={20}
r={r}
fill="none"
stroke="currentColor"
strokeWidth={7}
strokeDasharray={c}
strokeDashoffset={c * (1 - filled)}
className="transition-[stroke-dashoffset] duration-200 ease-snappy motion-reduce:transition-none"
/>
</svg>
);
}
const subscribeClock = (onChange: () => void) => {
const id = setInterval(onChange, 1000);
return () => clearInterval(id);
};
const readClock = () =>
new Date().toLocaleTimeString([], { hour: "2-digit", minute: "2-digit", hour12: false });
function Clock() {
const time = useSyncExternalStore(subscribeClock, readClock, () => "--:--");
return <time className="tabular-nums">{time}</time>;
}
function useTracked(mv: MotionValue<number>) {
const [value, setValue] = useState(() => mv.get());
useMotionValueEvent(mv, "change", setValue);
return value;
}
export type RadioTunerProps = {
stations?: Station[];
defaultBand?: Band;
/** Starting frequency per band: MHz for FM, kHz for AM. */
defaultFrequency?: Partial<Record<Band, number>>;
/** Any CSS colour. Defaults to the foreground, so it is neutral until you set one. */
accent?: string;
/** Called whenever the tuned (snapped) frequency or band changes. */
onTune?: (band: Band, frequency: number) => void;
className?: string;
};
export function RadioTuner({
stations = DEFAULT_STATIONS,
defaultBand = "FM",
defaultFrequency,
accent,
onTune,
className,
}: RadioTunerProps) {
const reduce = useReducedMotion();
const clipId = useId();
const [band, setBand] = useState<Band>(defaultBand);
const [recording, setRecording] = useState(false);
const fmValue = useMotionValue(defaultFrequency?.FM ?? 98.8);
const amValue = useMotionValue(defaultFrequency?.AM ?? 1010);
const fm = useTracked(fmValue);
const am = useTracked(amValue);
const spec = BANDS[band];
const mvFor = (b: Band) => (b === "FM" ? fmValue : amValue);
const tuned = snap(band === "FM" ? fm : am, spec);
const inBand = stations.filter((s) => s.band === band);
const nearest = inBand.reduce<Station | null>(
(best, s) =>
!best || Math.abs(s.frequency - tuned) < Math.abs(best.frequency - tuned) ? s : best,
null,
);
const distance = nearest ? Math.abs(nearest.frequency - tuned) : Infinity;
const strength = Math.max(0, 1 - distance / spec.reach);
const station = nearest && distance < spec.step * 1.5 ? nearest : null;
const onTuneRef = useRef(onTune);
useEffect(() => {
onTuneRef.current = onTune;
});
useEffect(() => {
onTuneRef.current?.(band, tuned);
}, [band, tuned]);
const anim = useRef<AnimationPlaybackControls | null>(null);
const keyTarget = useRef<number | null>(null);
const dialRef = useRef<HTMLDivElement>(null);
const glide = (b: Band, target: number) => {
anim.current?.stop();
const mv = mvFor(b);
if (reduce) mv.set(target);
else anim.current = animate(mv, target, SPRING);
};
const tuneBy = (steps: number) => {
const base = keyTarget.current ?? snap(mvFor(band).get(), spec);
const next = snap(base + steps * spec.step, spec);
keyTarget.current = next;
glide(band, next);
};
const seek = (dir: 1 | -1) => {
const base = keyTarget.current ?? snap(mvFor(band).get(), spec);
const sorted = inBand.map((s) => s.frequency).sort((a, b) => a - b);
const next =
dir > 0
? (sorted.find((f) => f > base + 1e-6) ?? spec.max)
: ([...sorted].reverse().find((f) => f < base - 1e-6) ?? spec.min);
keyTarget.current = next;
glide(band, next);
};
const onKeyDown = (e: React.KeyboardEvent) => {
const up = e.key === "ArrowUp" || e.key === "ArrowRight";
const down = e.key === "ArrowDown" || e.key === "ArrowLeft";
if (up || down) {
if (e.shiftKey) seek(up ? 1 : -1);
else tuneBy(up ? 1 : -1);
} else if (e.key === "PageUp") tuneBy(10);
else if (e.key === "PageDown") tuneBy(-10);
else if (e.key === "Home") tuneBy(-1e6);
else if (e.key === "End") tuneBy(1e6);
else return;
e.preventDefault();
};
// Pointer: drag to turn either ring (the press radius picks which one),
// flick to coast and land on a step, tap a spot to tune straight to it.
const drag = useRef<{
id: number;
band: Band;
y: number;
start: number;
moved: boolean;
unitsPerPx: number;
} | null>(null);
const toViewBox = (e: React.PointerEvent) => {
const rect = e.currentTarget.parentElement!.getBoundingClientRect();
return {
x: ((e.clientX - rect.left) / rect.width) * VB_W,
y: ((e.clientY - rect.top) / rect.height) * VB_H,
scale: rect.height / VB_H,
};
};
const onPointerDown = (e: React.PointerEvent<HTMLDivElement>) => {
if (e.button !== 0) return;
const { x, y, scale } = toViewBox(e);
const ring: Band = Math.hypot(CX - x, CY - y) < R_SPLIT ? "AM" : "FM";
const s = BANDS[ring];
anim.current?.stop();
keyTarget.current = null;
setBand(ring);
e.currentTarget.setPointerCapture(e.pointerId);
drag.current = {
id: e.pointerId,
band: ring,
y: e.clientY,
start: mvFor(ring).get(),
moved: false,
unitsPerPx: 1 / (scale * s.radius * s.deg * (Math.PI / 180)),
};
};
const onPointerMove = (e: React.PointerEvent<HTMLDivElement>) => {
const d = drag.current;
if (!d || d.id !== e.pointerId) return;
const dy = e.clientY - d.y;
if (Math.abs(dy) > 3) d.moved = true;
if (!d.moved) return;
const s = BANDS[d.band];
// Dragging down brings the higher numbers (above the needle) down to it.
mvFor(d.band).set(clamp(d.start + dy * d.unitsPerPx, s.min, s.max));
};
const onPointerUp = (e: React.PointerEvent<HTMLDivElement>) => {
const d = drag.current;
if (!d || d.id !== e.pointerId) return;
drag.current = null;
const s = BANDS[d.band];
const mv = mvFor(d.band);
if (!d.moved) {
const { x, y } = toViewBox(e);
const theta = (Math.atan2(CY - y, CX - x) * 180) / Math.PI;
glide(d.band, snap(mv.get() + unwarp(theta, s.deg), s));
return;
}
if (reduce) {
mv.set(snap(mv.get(), s));
return;
}
anim.current = animate(mv, mv.get(), {
type: "inertia",
velocity: mv.getVelocity(),
power: 0.35,
timeConstant: 260,
min: s.min,
max: s.max,
bounceStiffness: 400,
bounceDamping: 40,
modifyTarget: (t) => snap(t, s),
});
};
// Wheel and trackpad scroll turn the active ring, then settle on a step.
useEffect(() => {
const el = dialRef.current;
if (!el) return;
let settle: ReturnType<typeof setTimeout> | undefined;
const onWheel = (e: WheelEvent) => {
e.preventDefault();
anim.current?.stop();
keyTarget.current = null;
const s = BANDS[band];
const mv = band === "FM" ? fmValue : amValue;
const scale = el.parentElement!.getBoundingClientRect().height / VB_H;
const unitsPerPx = 1 / (scale * s.radius * s.deg * (Math.PI / 180));
mv.set(clamp(mv.get() - e.deltaY * unitsPerPx * 0.6, s.min, s.max));
clearTimeout(settle);
settle = setTimeout(() => {
const target = snap(mv.get(), s);
if (reduce) mv.set(target);
else anim.current = animate(mv, target, SPRING);
}, 120);
};
el.addEventListener("wheel", onWheel, { passive: false });
return () => {
el.removeEventListener("wheel", onWheel);
clearTimeout(settle);
};
}, [band, fmValue, amValue, reduce]);
const switchBand = (b: Band) => {
anim.current?.stop();
keyTarget.current = null;
// Land the band we're leaving on a step so it's tidy when we come back.
const leaving = mvFor(band);
leaving.set(snap(leaving.get(), spec));
setBand(b);
};
return (
<div
role="group"
aria-label="Radio tuner"
style={accent ? ({ "--radio-accent": accent } as React.CSSProperties) : undefined}
className={cn(
"@container relative aspect-[1280/878] w-full touch-manipulation overflow-hidden bg-card text-foreground select-none [--radio-accent:var(--foreground)]",
className,
)}
>
<Dial fm={fm} am={am} band={band} clipId={clipId} />
<div
ref={dialRef}
role="slider"
tabIndex={0}
aria-label={`${band} tuning dial`}
aria-orientation="vertical"
aria-valuemin={spec.min}
aria-valuemax={spec.max}
aria-valuenow={tuned}
aria-valuetext={`${tuned} ${spec.spokenUnit}${station ? `, ${station.name}` : ""}`}
onKeyDown={onKeyDown}
onPointerDown={onPointerDown}
onPointerMove={onPointerMove}
onPointerUp={onPointerUp}
onPointerCancel={onPointerUp}
className="absolute inset-y-0 left-0 w-[44%] cursor-grab touch-none rounded-[2cqw] outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset active:cursor-grabbing"
/>
{/* Status bar */}
<div className="absolute top-[6.4%] right-[3.5%] flex items-center gap-[3.4cqw]">
<button
type="button"
aria-pressed={recording}
onClick={() => setRecording((r) => !r)}
className="relative flex h-[3.4cqw] items-center gap-[0.9cqw] rounded-[0.8cqw] px-[1cqw] text-[max(9px,1.8cqw)] leading-none ring-1 ring-foreground/30 transition-[box-shadow] outline-none before:absolute before:-inset-2 hover:ring-foreground/50 focus-visible:ring-2 focus-visible:ring-ring"
>
REC
<span
className={cn(
"size-[0.8cqw] min-h-1 min-w-1 rounded-full bg-destructive transition-opacity duration-200",
recording ? "animate-pulse motion-reduce:animate-none" : "opacity-40",
)}
/>
<span className="sr-only">{recording ? "Stop recording" : "Start recording"}</span>
</button>
<span role="img" aria-label={`Signal ${Math.round(strength * 100)}%`}>
<Signal strength={strength} />
</span>
<span className="text-[max(12px,3.75cqw)] leading-none">
<Clock />
</span>
</div>
{/* Readout */}
<div className="absolute top-[27%] right-[6.2%] left-[44.6%] flex flex-col">
<div className="flex h-[5cqw] items-start pl-[5.6cqw] text-foreground/45">
<motion.span
key={station?.name ?? "none"}
initial={reduce ? false : { opacity: 0, y: "0.15em" }}
animate={{ opacity: station ? 1 : 0.6, y: 0 }}
transition={{ duration: 0.2, ease: [0.23, 1, 0.32, 1] }}
className="truncate text-[max(12px,3.6cqw)] leading-none tracking-tight"
>
{station?.name ?? "No station"}
</motion.span>
<span className="ml-[1.2cqw] text-[max(6px,1.15cqw)] leading-none tracking-wide uppercase">
Channel
</span>
</div>
<div
className="mt-[1.8cqw] flex h-[15.9cqw] items-center rounded-full bg-foreground/[0.06] pl-[4.7cqw] dark:bg-foreground/[0.1]"
aria-live="off"
>
<span className="text-[15cqw] leading-none font-normal tracking-[-0.04em]">
<Readout value={tuned} spec={spec} />
</span>
<span className="sr-only">{spec.unit}</span>
</div>
<div className="mt-[2.2cqw] flex gap-[2.2cqw] pl-[5cqw] text-[max(12px,3.6cqw)] leading-none tracking-tight">
{(["FM", "AM"] as const).map((b) => (
<button
key={b}
type="button"
aria-pressed={band === b}
onClick={() => switchBand(b)}
className={cn(
"relative rounded-sm transition-colors duration-200 outline-none before:absolute before:-inset-2 focus-visible:ring-2 focus-visible:ring-ring",
band === b ? "text-(--radio-accent)" : "text-foreground/25 hover:text-foreground/45",
)}
>
{b}
</button>
))}
</div>
</div>
</div>
);
}