Try it

9 × 9

Tap to start. Hold and slide up to lock, or left to discard.

Simulated recording. No microphone is accessed.

The interaction. The outline expands around complete control targets. Recording, pause, lock and discard remain interruptible.

One shared language. Permanent dots, selective light handoffs and clean outlined shells. Chalk, Carbon and Ember carry the family across sizes and themes.

Make it yours. The preview and installation use the same source. Pointer, touch and keyboard interactions share the same state model, with system reduced motion respected throughout.

Install

Add it with the shadcn CLI, or copy the source manually.

Terminal
npx shadcn@latest add https://seanportfol.io/r/dot-matrix-capture.json
Prefer a namespace? Register the registry once.
Terminal
npx shadcn@latest registry add @seanlynch=https://seanportfol.io/r/{name}.json
Terminal
npx shadcn@latest add @seanlynch/dot-matrix-capture

Usage

This is the working preview example. Save it in a separate file after installing the component. Recording, media clocks and requests are illustrative: connect their controlled state and callbacks to your application.

components/examples/capture-demo.tsx
'use client';

import { useState, useEffect, useRef, useCallback } from 'react';
import { MatrixCapture, type CaptureState } from '@/components/dot-matrix/capture-entry';

function usePreviewClock(running: boolean, advance: (seconds: number) => void, pause: () => void) {
  const frame = useRef<HTMLDivElement>(null);
  useEffect(() => {
    if (!running) return;
    const stopWhenHidden = () => { if (document.hidden) pause(); };
    const observer = new IntersectionObserver(([entry]) => { if (!entry.isIntersecting) pause(); });
    if (frame.current) observer.observe(frame.current);
    document.addEventListener('visibilitychange', stopWhenHidden);
    window.addEventListener('blur', pause);
    let last = performance.now();
    const timer = window.setInterval(() => {
      const now = performance.now();
      if (!document.hidden) advance((now - last) / 1000);
      last = now;
    }, 100);
    return () => {
      clearInterval(timer); observer.disconnect();
      document.removeEventListener('visibilitychange', stopWhenHidden);
      window.removeEventListener('blur', pause);
    };
  }, [running, advance, pause]);
  return frame;
}

export default function CaptureExample() {
  const [state, setState] = useState<CaptureState>('idle');
  const [elapsed, setElapsed] = useState(0);
  const advance = useCallback((dt: number) => setElapsed(t => t + dt), []);
  const pause = useCallback(() => setState(s => s === 'recording' ? 'paused' : s), []);
  const frame = usePreviewClock(state === 'recording', advance, pause);
  return <div ref={frame} style={{ width: '100%', display: 'grid', justifyItems: 'center' }}>
    <MatrixCapture state={state} elapsed={elapsed}
      onStart={() => { setElapsed(0); setState('recording'); }}
      onPause={pause} onResume={() => setState('recording')}
      onFinish={() => setState('saved')}
      onDiscard={() => { setState('idle'); setElapsed(0); }} />
  </div>;
}

API Reference

Props on Capture. Consult the included TypeScript source for supported native attributes.

PropTypeDefault
stateHost-owned recording state.'idle' | 'recording' | 'paused' | 'saved'–
elapsedRecorded seconds, supplied by your media adapter.number–
onStart / onPause / onResume / onFinish / onDiscardConnect each intent to your recording engine.() => void–
activityOptional normalized column levels. Without samples the mark stays steady.readonly number[]–
gridFixed cornerless lattice; glyphs are authored for each resolution.5 | 7 | 9 | 119
size48 / 56 / 64px primary controls with matching insets.'compact' | 'regular' | 'large''regular'
glyphSizingThe accepted optical scale is 22 / 24 / 26px.'optical' | 'footprint' | 'dot-weight''optical'
slowSlows animation only, never gestures, operation time or media clocks.booleanfalse
reducedMotionImmediate state clarity without indirect travel or activity loops. The system preference takes precedence.booleanfalse
disabledSuspend interaction and cancel active gestures.booleanfalse

Information

Category
Dot Matrix
Files
  • components/dot-matrix/MatrixCapture.tsx
  • components/dot-matrix/MatrixGlyph.tsx
  • components/dot-matrix/capture-entry.ts
  • components/dot-matrix/context.tsx
  • components/dot-matrix/dot-matrix.css
  • components/dot-matrix/glyphs.ts
  • components/dot-matrix/motion.ts
  • components/dot-matrix/tokens.ts
  • components/dot-matrix/useShell.ts
Dependencies
React 18.2 or 19 and React DOM; no additional runtime packages
Compatibility
React 18.2 / 19, TypeScript, CSS imports, Modern browsers
Version
0.1.0
Updated
Oct 1, 2026
Registry
dot-matrix-capture