No.245 · AI & Chat
Voice Capsule
Hold to talk: the mic swells into a capsule with a live waveform and timer. Slide left and the capsule reddens — let go there to throw it away; let go anywhere else and it becomes a voice note.
The prompt
Written for the variant you picked above: Paper
Build a press-and-hold voice input. At rest it's a 56px round ink mic button. On press (pointer capture, touch-action none, context menu suppressed, 10ms haptic) the button swells to 1.12× with a soft accent halo, and a capsule grows out to its left (width transition 480ms expo-out) holding a blinking rose record dot, a tabular timer, a 'Slide to cancel' hint with a nudging chevron, and a live waveform of 28 bars fed by a level function (synthetic speech-like bursts here; an AnalyserNode in production), each bar's height a CSS variable updated every frame. Dragging left moves the hint with the finger; past 90px the gesture is 'armed': the capsule and bars warm toward rose in proportion, the mic turns rose and its glyph morphs into a bin. Releasing while armed (or recording under 0.4s) discards it — the capsule shakes and fades. Releasing anywhere else sends: the capsule collapses back into the mic and a small 'Voice note · 0:04' pill rises into the list above. Space/Enter held works the same; Escape cancels. Paper and night themes. Selected variant — Paper (paper): Palette for this theme (Paper): --vc-accent #c4673f; --vc-faint #a39b8f; --vc-ink #1f1b16; --vc-line rgb(31 27 22 / 0.1); --vc-muted #6b645a; --vc-rose #c2413a; --vc-surface #fffdf8. Treat these as the root colour tokens, one value per role, and name them to suit your code. Select it with the theme option set to "paper". Keep every dimension, spacing value, state and motion from the brief unchanged, and keep text at 4.5:1 contrast or better on these surfaces. This selection takes precedence over references to other themes or options in the general brief. Implement this selected appearance; do not add a variant picker or alternative appearances unless requested. Implementation requirements: Use React and TypeScript. Keep the component self-contained, with uniquely scoped CSS and no animation libraries. Include required imports, styles and font setup in the result. Interaction: Hold to record; slide left past the threshold to arm cancel; release to send or discard. Space/Enter hold also records; Escape cancels. Motion: 480ms capsule growth; per-frame waveform bars (90ms height smoothing); proportional rose warming while dragging; glyph → bin morph; shake on discard; note pill rise 520ms. Accessibility: A real button whose label changes with state; keyboard hold supported; outcomes announced assertively ('Voice note added' / 'Recording discarded'). Reduced motion keeps the states without the motion. Responsive behavior: The capsule fills the available width up to 24rem. Touch: Designed for thumbs: pointer capture keeps tracking outside the button; long-press menus and text selection are suppressed. Preserve keyboard access, visible focus and reduced-motion behavior. Keep fictional demo data and simulated service calls in a separate usage example; expose callbacks for real actions and recover from rejected requests. Keep usage-example links inside the demo: use local buttons or prevent navigation. Demonstration links must not navigate to Vitrine routes or open other pages; preserve real URL support in the reusable component itself. Verify the result at narrow and wide viewport sizes, with keyboard input and reduced motion enabled.
Notes
- Interaction
- Hold to record; slide left past the threshold to arm cancel; release to send or discard. Space/Enter hold also records; Escape cancels.
- Motion
- 480ms capsule growth; per-frame waveform bars (90ms height smoothing); proportional rose warming while dragging; glyph → bin morph; shake on discard; note pill rise 520ms.
- Accessibility
- A real button whose label changes with state; keyboard hold supported; outcomes announced assertively ('Voice note added' / 'Recording discarded'). Reduced motion keeps the states without the motion.
- Responsive
- The capsule fills the available width up to 24rem.
- On touch
- Designed for thumbs: pointer capture keeps tracking outside the button; long-press menus and text selection are suppressed.