Record button preview
The signature piece: a hairline box with a legend on its frame, an italic question and a ringed red dot that records, with a ticking timer and a live hairline waveform.
Part of the style
Typewriter Red Dot
7 parts that belong together, with their tokens, type and rules.
https://kitbash.me/components/typewriter-red-dot/recorder/figma.html?palette=ae487a995d89da2c
Use the Figma MCP server (https://mcp.figma.com/mcp). Download https://kitbash.me/components/typewriter-red-dot/recorder/figma.html?palette=ae487a995d89da2c and pass that whole HTML document to the html_to_figma tool, so the part "Record button preview" lands as editable layers in my open Figma file. Fonts come from Google Fonts: if a face is missing in Figma, pick the closest one.
Code
<style>
/* Goes after the pack's base.css */
:root {
--paper: #1d1522;
--ink: #fffeff;
--ink-body: #fcf1ff;
--ink-soft: #998c9d;
--ink-faint: #3c3342;
--rule: #382f3e;
--record: #8c4a9b;
}
</style>
<section class="recorder">
<p class="recorder__label">what your callers see</p>
<figure class="recorder__frame">
<figcaption class="recorder__legend">line preview</figcaption>
<p class="recorder__question">what kept you awake this week?</p>
<canvas class="recorder__wave" role="img" aria-label="A hairline waveform of the voice being recorded"></canvas>
<button class="recorder__button" type="button" aria-pressed="false" aria-label="Start recording">
<span class="recorder__dot"></span>
</button>
<p class="recorder__status" aria-live="polite">
<span class="recorder__state">tap to record</span>
<span class="recorder__sep" aria-hidden="true">·</span>
<span class="recorder__time">0:00</span>
<span class="recorder__sep" aria-hidden="true">·</span>
<span>no name asked</span>
</p>
</figure>
</section>
<style>
.recorder {
padding: var(--space-xl) var(--edge) var(--section-space);
}
.recorder__label {
margin: 0 0 var(--space-l);
color: var(--ink-soft);
font-size: var(--text-label);
letter-spacing: var(--track-label);
text-transform: uppercase;
}
.recorder__frame {
position: relative;
display: grid;
justify-items: center;
gap: var(--space-l);
margin: 0;
padding: var(--space-xl) var(--space-l) var(--space-l);
border: var(--line) solid var(--rule);
}
.recorder__legend {
position: absolute;
top: 0;
left: var(--space-l);
padding: 0 var(--space-s);
translate: 0 -50%;
background: var(--paper);
color: var(--ink-soft);
font-size: var(--text-label);
letter-spacing: var(--track-label);
text-transform: uppercase;
}
.recorder__question {
max-width: 26rem;
margin: 0;
color: var(--ink);
font-size: var(--text-l);
font-style: italic;
line-height: 1.5;
text-align: center;
}
.recorder__wave {
width: min(100%, 26rem);
height: 44px;
color: var(--ink-soft);
}
.recorder.is-live .recorder__wave { color: var(--ink); }
.recorder__button {
display: grid;
place-items: center;
width: 76px;
height: 76px;
padding: 0;
border: 2px solid var(--ink);
border-radius: 50%;
background: transparent;
cursor: pointer;
transition: transform 130ms var(--ease);
}
.recorder__button:hover { transform: scale(1.04); }
.recorder__button:active { transform: scale(0.94); }
.recorder__button:focus-visible {
outline: var(--line) dashed var(--ink);
outline-offset: 5px;
}
.recorder__dot {
width: 26px;
height: 26px;
border-radius: 50%;
background: var(--record);
transition: border-radius var(--quick) var(--ease), transform var(--quick) var(--ease);
}
.recorder.is-live .recorder__dot {
border-radius: 3px;
transform: scale(0.8);
}
.recorder__status {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 0 var(--space-s);
margin: 0;
color: var(--ink-soft);
font-size: var(--text-label);
letter-spacing: var(--track-label);
text-transform: uppercase;
}
.recorder.is-live .recorder__state,
.recorder.is-live .recorder__time { color: var(--record); }
.recorder__time { font-variant-numeric: tabular-nums; }
</style>
<script>
(() => {
const still = matchMedia('(prefers-reduced-motion: reduce)');
function paint(context, width, height, seconds, live) {
context.clearRect(0, 0, width, height);
context.strokeStyle = getComputedStyle(context.canvas).color;
context.lineWidth = 1;
context.beginPath();
const mid = height / 2;
const step = 3;
for (let x = 0; x <= width; x += step) {
const fade = Math.sin((x / width) * Math.PI);
let amp = 0.6;
if (live) {
const t = seconds * 6 - x * 0.045;
amp = (Math.sin(t) * 0.5 + Math.sin(t * 2.7 + 1.3) * 0.3 + Math.sin(t * 0.6) * 0.4 + 0.3) * mid * 0.85;
amp = Math.abs(amp) * fade;
} else {
amp = (1 + Math.sin(seconds * 1.4 + x * 0.08)) * fade;
}
context.moveTo(x + 0.5, mid - amp);
context.lineTo(x + 0.5, mid + amp + 0.5);
}
context.stroke();
}
document.querySelectorAll('.recorder').forEach((root) => {
const canvas = root.querySelector('.recorder__wave');
const button = root.querySelector('.recorder__button');
const state = root.querySelector('.recorder__state');
const time = root.querySelector('.recorder__time');
const context = canvas.getContext('2d');
let frame = 0;
let visible = false;
let live = false;
let started = 0;
let timer = 0;
const draw = (now) => paint(context, canvas.clientWidth, canvas.clientHeight, now / 1000, live);
const fit = () => {
const density = Math.min(2, devicePixelRatio || 1);
canvas.width = canvas.clientWidth * density;
canvas.height = canvas.clientHeight * density;
context.setTransform(density, 0, 0, density, 0, 0);
draw(performance.now());
};
const tick = (now) => {
draw(now);
frame = requestAnimationFrame(tick);
};
const run = () => {
cancelAnimationFrame(frame);
if (visible && !still.matches) frame = requestAnimationFrame(tick);
else draw(performance.now());
};
new ResizeObserver(fit).observe(canvas);
new IntersectionObserver(([entry]) => {
visible = entry.isIntersecting;
run();
}).observe(canvas);
const show = () => {
const seconds = Math.floor((Date.now() - started) / 1000);
time.textContent = `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, '0')}`;
if (seconds >= 90) toggle();
};
const toggle = () => {
live = !live;
root.classList.toggle('is-live', live);
button.setAttribute('aria-pressed', String(live));
button.setAttribute('aria-label', live ? 'Stop recording' : 'Start recording');
state.textContent = live ? 'recording' : 'tap to record';
clearInterval(timer);
if (live) {
started = Date.now();
time.textContent = '0:00';
timer = setInterval(show, 250);
}
run();
};
button.addEventListener('click', toggle);
});
})();
</script>