# Voice recorder

Record or attach a reviewable audio prompt through an injected media adapter.

Access: pro. Category: Forms. Kind: composite.

## When to use

- Use it when a page needs record or attach a reviewable audio prompt through an injected media adapter.
- Choose it when the host application can supply the required state and keep business logic outside the presentation component.

## Alternatives

- Choose form-field instead when a labeled email field with validation and help text is the actual interface need, rather than voice recorder.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Voice recorder

```sh
npx shadcn@latest add @tidal-pro/voice-recorder
```

Stylesheets: `components/ui/tidal.css`, `components/ui/voice-recorder.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/voice-recorder.css";
import{TidalVoiceRecorder}from"./components/ui/voice-recorder";
export default(p:Parameters<typeof TidalVoiceRecorder>[0])=><div className="tidal-scope"><TidalVoiceRecorder {...p}/></div>;
```

## Structured props

- `TidalVoiceRecorder.adapter: TidalVoiceRecorderAdapter`: Required adapter value accepted by this exported component.
- `TidalVoiceRecorder.consentNotice: ReactNode`: Required consent notice value accepted by this exported component.
- `TidalVoiceRecorder.durationMs: number`: Required duration ms value accepted by this exported component.
- `TidalVoiceRecorder.permission: TidalVoiceRecorderPermission`: Required permission value accepted by this exported component.
- `TidalVoiceRecorder.status: TidalVoiceRecorderStatus`: Required status value accepted by this exported component.
- `TidalVoiceRecorder.title: ReactNode`: Required title value accepted by this exported component.
- `TidalVoiceRecorder.accept?: string | undefined` (default "audio/*"): Optional accept value accepted by this exported component.
- `TidalVoiceRecorder.aria-disabled?: undefined`: Accessible disabled supplied by the consumer.
- `TidalVoiceRecorder.aria-label?: undefined`: Accessible label supplied by the consumer.
- `TidalVoiceRecorder.attachmentInputProps?: AttachmentInputProps | undefined`: Optional attachment input props value accepted by this exported component.
- `TidalVoiceRecorder.attachProps?: RecorderActionProps | undefined`: Optional attach props value accepted by this exported component.
- `TidalVoiceRecorder.clip?: TidalVoiceClip | null | undefined` (default null): Optional clip value accepted by this exported component.
- `TidalVoiceRecorder.clipAudioProps?: ClipAudioProps | undefined`: Optional clip audio props value accepted by this exported component.
- `TidalVoiceRecorder.clipAudioRef?: Ref<HTMLAudioElement> | undefined`: Optional clip audio ref value accepted by this exported component.
- `TidalVoiceRecorder.description?: ReactNode`: Optional description value accepted by this exported component.
- `TidalVoiceRecorder.disabled?: boolean | undefined` (default false): Optional disabled value accepted by this exported component.
- `TidalVoiceRecorder.discardProps?: RecorderActionProps | undefined`: Optional discard props value accepted by this exported component.
- `TidalVoiceRecorder.error?: ReactNode`: Optional error value accepted by this exported component.
- `TidalVoiceRecorder.footer?: ReactNode`: Optional footer value accepted by this exported component.
- `TidalVoiceRecorder.formatDuration?: ((durationMs: number) => string) | undefined` (default defaultDuration): Optional format duration value accepted by this exported component.
- `TidalVoiceRecorder.formatLevel?: ((level: number) => string) | undefined` (default (value) => `${Math.round(value * 100)}%`): Optional format level value accepted by this exported component.
- `TidalVoiceRecorder.headingLevel?: "h2" | "h3" | "h4" | "h5" | undefined` (default "h2"): Optional heading level value accepted by this exported component.
- `TidalVoiceRecorder.labels?: Partial<TidalVoiceRecorderLabels> | undefined`: Optional labels value accepted by this exported component.
- `TidalVoiceRecorder.level?: number | null | undefined` (default null): Optional level value accepted by this exported component.
- `TidalVoiceRecorder.onAdapterError?: ((error: unknown, action: TidalVoiceRecorderAction) => void) | undefined`: Callback invoked when the adapter error interaction is proposed.
- `TidalVoiceRecorder.pauseProps?: RecorderActionProps | undefined`: Optional pause props value accepted by this exported component.
- `TidalVoiceRecorder.resumeProps?: RecorderActionProps | undefined`: Optional resume props value accepted by this exported component.
- `TidalVoiceRecorder.startProps?: RecorderActionProps | undefined`: Optional start props value accepted by this exported component.
- `TidalVoiceRecorder.stopProps?: RecorderActionProps | undefined`: Optional stop props value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/voice-recorder.tsx) | [Manifest](https://tidalui.com/examples/voice-recorder.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
import "./components/ui/tidal.css";

import { useEffect, useMemo, useRef, useState } from "react";

import { TidalVoiceRecorder, type TidalVoiceClip, type TidalVoiceRecorderPermission, type TidalVoiceRecorderStatus } from "./components/ui/voice-recorder";

import "./components/ui/voice-recorder.css";



const syntheticClip = "/voice-recorder-sample.wav";

export function VoiceRecorderDemo() {
  const [status, setStatus] = useState<TidalVoiceRecorderStatus>("idle");
  const [permission, setPermission] =
    useState<TidalVoiceRecorderPermission>("prompt");
  const [durationMs, setDurationMs] = useState(0);
  const [level, setLevel] = useState<number | null>(null);
  const [clip, setClip] = useState<TidalVoiceClip | null>(null);
  const objectUrl = useRef<string | null>(null);

  const releaseObjectUrl = () => {
    if (!objectUrl.current) return;
    URL.revokeObjectURL(objectUrl.current);
    objectUrl.current = null;
  };

  useEffect(() => releaseObjectUrl, []);

  const adapter = useMemo(
    () => ({
      start: () => {
        releaseObjectUrl();
        setClip(null);
        setPermission("granted");
        setDurationMs(250);
        setLevel(0.62);
        setStatus("recording" as const);
      },
      pause: () => {
        setDurationMs(500);
        setLevel(0);
        setStatus("paused" as const);
      },
      resume: () => {
        setDurationMs(750);
        setLevel(0.48);
        setStatus("recording" as const);
      },
      stop: () => {
        setDurationMs(1_000);
        setLevel(0);
        setClip({
          src: syntheticClip,
          label: "Synthetic one-second tone sample",
        });
        setStatus("ready" as const);
      },
      discard: () => {
        releaseObjectUrl();
        setClip(null);
        setDurationMs(0);
        setLevel(null);
        setStatus("idle" as const);
      },
      attach: (file: File) => {
        releaseObjectUrl();
        const nextUrl = URL.createObjectURL(file);
        objectUrl.current = nextUrl;
        setPermission("granted");
        setDurationMs(0);
        setLevel(null);
        setClip({ src: nextUrl, label: file.name });
        setStatus("ready" as const);
      },
    }),
    [],
  );

  return (
    <TidalVoiceRecorder
      title="Voice note"
      description="Review a short audio prompt before handing it to your own workflow."
      consentNotice="Choose Start recording to run a synthetic local state sequence. This preview never captures audio or requests microphone access."
      status={status}
      permission={permission}
      durationMs={durationMs}
      level={level}
      clip={clip}
      adapter={adapter}
      footer="Local sample only. Nothing is uploaded, transcribed, stored or sent."
    />
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <VoiceRecorderDemo />
    </div>
  );
}

```

## Gotchas

- The host application owns data, validation, persistence, navigation, and service side effects described by this API.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order.","Arrow-key behavior follows the exported composite-control implementation."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

Required title, visible consentNotice, controlled status (idle/requesting/recording/paused/ready/error), permission (prompt/granted/denied/unavailable), finite nonnegative durationMs and injected adapter. The adapter owns start, pause, resume, stop and discard; optional attach receives the selected local File. The component never accesses mediaDevices, MediaRecorder or a microphone by itself. Optional level is null/omitted or a finite 0..1 value. Ready requires a consumer-owned clip with nonblank src and accessible label; native audio controls never autoplay and default to preload none. Consumer-native action handlers run first and can prevent adapter calls. Async adapter operations receive a local pending guard, adapter failures show localized feedback and report through onAdapterError, and controlled status remains consumer-owned. Optional root attributes/ref, per-action native button props/React 19 refs, native attachment input props/ref, audio props/ref, formatters, error/footer, disabled, translated labels and heading level are supported. Owned accessible naming, replacement markup, action semantics, file-input type/value/form/name/capture and audio source/controls/autoplay are excluded and runtime-stripped. Permission denial and unavailable/error/configuration states remain explicit. No automatic permission request, recording timer, playback, upload, transcription, storage, analytics or custom network request is included. The demo uses a deterministic one-second synthetic tone WAV and an optional local object URL only after a person chooses a file.
