edbnedbn/ui
ComponentsMapsAudioPDF
GitHub stars
Explorer
Audio
Chat
Audio
Display

API Reference

Props, hooks, and shared types for all Audio components. Built on the Web Audio API and MediaRecorder API.

On this page

Chat

MessageConversationChatInputResponseThinkingIndicatorPromptSuggestionsFeedbackTokenCounter

Audio

AudioPlayerScrubBarLiveWaveformBarVisualizerWaveformAudioRecorderMicSelectorVoiceButton

Display & Hooks

MatrixShimmeringTextCodeBlockSpeechInputConversationBarTranscriptViewerVoicePickerOrb
useAudioPlayeruseAudioVolumeuseAudioDevicesuseMultibandVolumeuseBarAnimator

Chat Components

Message

Chat message bubble with role-based styling. Uses compound pattern with MessageContent and MessageAvatar.

Sub-components

MessageContent — Content wrapper with variant styling. MessageAvatar — Avatar with image or initials fallback.

Propfrom
Type"user" | "assistant"
Default—
DescriptionMessage alignment and styling based on sender role.
Propchildren
TypeReactNode
Default—
DescriptionMessage content (typically MessageContent + optional MessageAvatar).
PropTypeDefaultDescription
from"user" | "assistant"—Message alignment and styling based on sender role.
childrenReactNode—Message content (typically MessageContent + optional MessageAvatar).

Conversation

Auto-scrolling container powered by use-stick-to-bottom. Stays pinned to the bottom during streaming.

Sub-components

ConversationContent — Scrollable viewport. ConversationEmptyState — Shown when no messages exist. ConversationScrollButton — Scroll-to-bottom button.

Propchildren
TypeReactNode
Default—
DescriptionConversation content (messages, empty state).
PropTypeDefaultDescription
childrenReactNode—Conversation content (messages, empty state).

ChatInput

Multi-modal chat input with auto-resize textarea, keyboard shortcuts (Enter to send), and slots for actions.

Propplaceholder
Typestring
Default"Type a message…"
DescriptionTextarea placeholder text.
Propvalue
Typestring
Default—
DescriptionControlled textarea value.
ProponValueChange
Type(value: string) => void
Default—
DescriptionCalled when the textarea value changes.
ProponSubmit
Type(value: string) => void
Default—
DescriptionCalled when the user submits (Enter key).
Propdisabled
Typeboolean
Defaultfalse
DescriptionDisables the input.
PropmaxRows
Typenumber
Default5
DescriptionMaximum number of rows before scrolling.
Propleading
TypeReactNode
Default—
DescriptionContent rendered before the textarea.
Proptrailing
TypeReactNode
Default—
DescriptionContent rendered after the textarea.
PropTypeDefaultDescription
placeholderstring"Type a message…"Textarea placeholder text.
valuestring—Controlled textarea value.
onValueChange(value: string) => void—Called when the textarea value changes.
onSubmit(value: string) => void—Called when the user submits (Enter key).
disabledbooleanfalseDisables the input.
maxRowsnumber5Maximum number of rows before scrolling.
leadingReactNode—Content rendered before the textarea.
trailingReactNode—Content rendered after the textarea.

Response

Memoized wrapper around Streamdown. Accepts all Streamdown props — renders streaming markdown with syntax highlighting and animations. Only re-renders when children changes.

ThinkingIndicator

Animated loading indicator with three visual variants for AI thinking states.

Propvariant
Type"dots" | "pulse" | "shimmer"
Default"dots"
DescriptionAnimation variant.
Propsize
Type"sm" | "md" | "lg"
Default"md"
DescriptionSize of the indicator.
Proplabel
Typestring
Default—
DescriptionOptional label text displayed alongside the indicator.
PropTypeDefaultDescription
variant"dots" | "pulse" | "shimmer""dots"Animation variant.
size"sm" | "md" | "lg""md"Size of the indicator.
labelstring—Optional label text displayed alongside the indicator.

PromptSuggestions

Grid or list of clickable suggestion cards. Each suggestion has a title, optional description, icon, and value.

Suggestion type

{ title: string; description?: string; icon?: ReactNode; value?: string }

Propsuggestions
TypeSuggestion[]
Default—
DescriptionArray of suggestion objects to display.
ProponSelect
Type(value: string) => void
Default—
DescriptionCalled when a suggestion is clicked.
Propheading
Typestring
Default—
DescriptionOptional heading above the suggestions.
Proplayout
Type"list" | "grid"
Default"grid"
DescriptionLayout mode.
Propcolumns
Type1 | 2 | 3
Default2
DescriptionNumber of grid columns.
PropTypeDefaultDescription
suggestionsSuggestion[]—Array of suggestion objects to display.
onSelect(value: string) => void—Called when a suggestion is clicked.
headingstring—Optional heading above the suggestions.
layout"list" | "grid""grid"Layout mode.
columns1 | 2 | 32Number of grid columns.

Feedback

Thumbs up/down feedback bar with copy and regenerate actions. Designed for AI message responses.

FeedbackValue type

"positive" | "negative" | null

Propvalue
Type"positive" | "negative" | null
Default—
DescriptionControlled feedback value.
ProponValueChange
Type(value: FeedbackValue) => void
Default—
DescriptionCalled when feedback changes.
ProponCopy
Type() => void
Default—
DescriptionCalled when copy button is clicked.
ProponRegenerate
Type() => void
Default—
DescriptionCalled when regenerate button is clicked.
PropshowCopy
Typeboolean
Defaulttrue
DescriptionShow the copy action button.
PropshowRegenerate
Typeboolean
Defaulttrue
DescriptionShow the regenerate action button.
PropTypeDefaultDescription
value"positive" | "negative" | null—Controlled feedback value.
onValueChange(value: FeedbackValue) => void—Called when feedback changes.
onCopy() => void—Called when copy button is clicked.
onRegenerate() => void—Called when regenerate button is clicked.
showCopybooleantrueShow the copy action button.
showRegeneratebooleantrueShow the regenerate action button.

TokenCounter

Token usage display with progress bar, model badge, and optional cost calculation.

Propused
Typenumber
Default—
DescriptionNumber of tokens used (required).
Proplimit
Typenumber
Default—
DescriptionToken limit (required).
Propmodel
Typestring
Default—
DescriptionModel name displayed as a badge.
PropcostPer1k
Typenumber
Default—
DescriptionCost per 1,000 tokens for cost calculation.
PropshowProgress
Typeboolean
Defaulttrue
DescriptionShow the progress bar.
PropformatNumber
Type(n: number) => string
Defaultbuilt-in
DescriptionCustom number formatter for token counts.
Propsize
Type"sm" | "md" | "lg"
Default"md"
DescriptionSize variant.
PropTypeDefaultDescription
usednumber—Number of tokens used (required).
limitnumber—Token limit (required).
modelstring—Model name displayed as a badge.
costPer1knumber—Cost per 1,000 tokens for cost calculation.
showProgressbooleantrueShow the progress bar.
formatNumber(n: number) => stringbuilt-inCustom number formatter for token counts.
size"sm" | "md" | "lg""md"Size variant.

Audio Components

AudioPlayer

Compound audio player built on a shared context. Wrap children in AudioPlayerProvider and compose with sub-components.

example.tsx
21 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import {
  AudioPlayerProvider,
  AudioPlayerButton,
  AudioPlayerProgress,
  AudioPlayerTime,
  AudioPlayerDuration,
} from "@/components/ui/audio/audio-player";

const track = { id: "1", src: "/audio/track.mp3", data: { name: "My Track" } };

export function Player() {
  return (
    <AudioPlayerProvider>
      <div className="flex items-center gap-3">
        <AudioPlayerButton item={track} />
        <AudioPlayerProgress />
        <AudioPlayerTime /> / <AudioPlayerDuration />
      </div>
    </AudioPlayerProvider>
  );
}

AudioPlayerItem<TData>

Propid
Typestring | number
Default—
DescriptionUnique identifier for the track.
Propsrc
Typestring
Default—
DescriptionAudio source URL.
Propdata
TypeTData
Default—
DescriptionOptional custom data attached to the track (generic).
PropTypeDefaultDescription
idstring | number—Unique identifier for the track.
srcstring—Audio source URL.
dataTData—Optional custom data attached to the track (generic).

AudioPlayerButton

Propitem
TypeAudioPlayerItem<TData>
Default—
DescriptionTrack to play/pause. If omitted, toggles the active item.
PropTypeDefaultDescription
itemAudioPlayerItem<TData>—Track to play/pause. If omitted, toggles the active item.

AudioPlayerSpeed

Propspeeds
Typereadonly number[]
Default[0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2]
DescriptionAvailable playback speeds in the dropdown.
PropTypeDefaultDescription
speedsreadonly number[][0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2]Available playback speeds in the dropdown.

Additional sub-components: AudioPlayerProgress, AudioPlayerTime, AudioPlayerDuration, AudioPlayerSpeedButtonGroup.

Hooks: useAudioPlayer() returns the full player API. useAudioPlayerTime() returns the current time (number).

ScrubBar

Compound timeline scrubber with draggable thumb. Compose ScrubBarContainer > ScrubBarTrack > ScrubBarProgress + ScrubBarThumb.

Sub-components

ScrubBarTrack, ScrubBarProgress, ScrubBarThumb, ScrubBarTimeLabel

Propduration
Typenumber
Default—
DescriptionTotal duration in seconds (required).
Propvalue
Typenumber
Default—
DescriptionCurrent time in seconds (required).
ProponScrub
Type(time: number) => void
Default—
DescriptionCalled during scrubbing with the current time.
ProponScrubStart
Type() => void
Default—
DescriptionCalled when scrubbing begins.
ProponScrubEnd
Type() => void
Default—
DescriptionCalled when scrubbing ends.
PropTypeDefaultDescription
durationnumber—Total duration in seconds (required).
valuenumber—Current time in seconds (required).
onScrub(time: number) => void—Called during scrubbing with the current time.
onScrubStart() => void—Called when scrubbing begins.
onScrubEnd() => void—Called when scrubbing ends.

LiveWaveform

Canvas-based real-time audio waveform from microphone or stream input. Supports scrolling and static rendering modes.

Propactive
Typeboolean
Defaultfalse
DescriptionWhether microphone capture is active.
Propprocessing
Typeboolean
Defaultfalse
DescriptionShow processing animation.
PropdeviceId
Typestring
Default—
DescriptionSpecific audio input device ID.
PropbarWidth
Typenumber
Default3
DescriptionWidth of each bar in pixels.
PropbarHeight
Typenumber
Default4
DescriptionHeight of each bar in pixels.
PropbarGap
Typenumber
Default1
DescriptionGap between bars in pixels.
PropbarRadius
Typenumber
Default1.5
DescriptionCorner radius of each bar.
PropbarColor
Typestring
DefaultcurrentColor
DescriptionCSS color for the bars.
PropfadeEdges
Typeboolean
Defaulttrue
DescriptionApply fade gradient at edges.
PropfadeWidth
Typenumber
Default24
DescriptionWidth of edge fade gradient in pixels.
Propheight
Typestring | number
Default64
DescriptionContainer height.
Propsensitivity
Typenumber
Default1
DescriptionVolume multiplier for sensitivity.
PropsmoothingTimeConstant
Typenumber
Default0.8
DescriptionAnalyserNode smoothing time constant (0–1).
PropfftSize
Typenumber
Default256
DescriptionFFT size for frequency analysis.
ProphistorySize
Typenumber
Default60
DescriptionNumber of historical frames to retain.
PropupdateRate
Typenumber
Default30
DescriptionTarget render frames per second.
Propmode
Type"scrolling" | "static"
Default"static"
DescriptionRendering mode — scrolling or static bars.
ProponError
Type(error: Error) => void
Default—
DescriptionCalled on microphone/audio errors.
ProponStreamReady
Type(stream: MediaStream) => void
Default—
DescriptionCalled when the media stream is ready.
ProponStreamEnd
Type() => void
Default—
DescriptionCalled when the media stream ends.
PropTypeDefaultDescription
activebooleanfalseWhether microphone capture is active.
processingbooleanfalseShow processing animation.
deviceIdstring—Specific audio input device ID.
barWidthnumber3Width of each bar in pixels.
barHeightnumber4Height of each bar in pixels.
barGapnumber1Gap between bars in pixels.
barRadiusnumber1.5Corner radius of each bar.
barColorstringcurrentColorCSS color for the bars.
fadeEdgesbooleantrueApply fade gradient at edges.
fadeWidthnumber24Width of edge fade gradient in pixels.
heightstring | number64Container height.
sensitivitynumber1Volume multiplier for sensitivity.
smoothingTimeConstantnumber0.8AnalyserNode smoothing time constant (0–1).
fftSizenumber256FFT size for frequency analysis.
historySizenumber60Number of historical frames to retain.
updateRatenumber30Target render frames per second.
mode"scrolling" | "static""static"Rendering mode — scrolling or static bars.
onError(error: Error) => void—Called on microphone/audio errors.
onStreamReady(stream: MediaStream) => void—Called when the media stream is ready.
onStreamEnd() => void—Called when the media stream ends.

BarVisualizer

Hooks for building real-time frequency bar visualizers. This file exports three hooks — compose them to create custom bar UIs. Uses Web Audio API AnalyserNode under the hood.

useAudioVolume(mediaStream, options?) → number

Returns a single volume value (0–1) from a MediaStream.

PropertymediaStream
TypeMediaStream | null | undefined
DescriptionAudio source media stream.
Propertyoptions.fftSize
Typenumber
DescriptionFFT size for the analyser (default: 32).
Propertyoptions.smoothingTimeConstant
Typenumber
DescriptionSmoothing time constant (default: 0).
Propertyoptions.minDecibels
Typenumber
DescriptionMinimum decibels for the analyser.
Propertyoptions.maxDecibels
Typenumber
DescriptionMaximum decibels for the analyser.
PropertyTypeDescription
mediaStreamMediaStream | null | undefinedAudio source media stream.
options.fftSizenumberFFT size for the analyser (default: 32).
options.smoothingTimeConstantnumberSmoothing time constant (default: 0).
options.minDecibelsnumberMinimum decibels for the analyser.
options.maxDecibelsnumberMaximum decibels for the analyser.

useMultibandVolume(mediaStream, options?) → number[]

Splits audio into configurable frequency bands. Returns volume per band.

PropertymediaStream
TypeMediaStream | null | undefined
DescriptionAudio source media stream.
Propertyoptions.bands
Typenumber
DescriptionNumber of frequency bands (default: 5).
Propertyoptions.loPass
Typenumber
DescriptionLow-pass frequency cutoff in Hz (default: 100).
Propertyoptions.hiPass
Typenumber
DescriptionHigh-pass frequency cutoff in Hz (default: 600).
Propertyoptions.updateInterval
Typenumber
DescriptionUpdate interval in ms (default: 32).
PropertyTypeDescription
mediaStreamMediaStream | null | undefinedAudio source media stream.
options.bandsnumberNumber of frequency bands (default: 5).
options.loPassnumberLow-pass frequency cutoff in Hz (default: 100).
options.hiPassnumberHigh-pass frequency cutoff in Hz (default: 600).
options.updateIntervalnumberUpdate interval in ms (default: 32).

useBarAnimator(state, columns, interval) → number[]

Returns highlighted bar indices based on agent state. Used for preset animation patterns.

Propertystate
TypeAgentState | undefined
DescriptionAgent state for preset highlight patterns (connecting, initializing, listening, speaking, thinking).
Propertycolumns
Typenumber
DescriptionNumber of columns/bars to animate.
Propertyinterval
Typenumber
DescriptionAnimation interval in ms.
PropertyTypeDescription
stateAgentState | undefinedAgent state for preset highlight patterns (connecting, initializing, listening, speaking, thinking).
columnsnumberNumber of columns/bars to animate.
intervalnumberAnimation interval in ms.

AgentState type

"connecting" | "initializing" | "listening" | "speaking" | "thinking"

Waveform

Waveform family with static, scrolling, scrubber, microphone, live-microphone, and recording variants.

Utility

downsample(data, targetBars) — Downsamples audio data to a target number of bars.

Family exports: AudioScrubber, StaticWaveform, ScrollingWaveform, MicrophoneWaveform, LiveMicrophoneWaveform, and RecordingWaveform.

Propdata
TypeFloat32Array | number[]
Default—
DescriptionWaveform amplitude data (values -1 to 1).
Propbars
Typenumber
Default100
DescriptionNumber of bars to render.
Propprogress
Typenumber
Default0
DescriptionPlayback progress (0–1).
PropplayedColor
Typestring
Defaultprimary
DescriptionColor of played portion bars.
PropunplayedColor
Typestring
Defaultmuted
DescriptionColor of unplayed portion bars.
PropbarColor
Typestring
Default—
DescriptionShared bar color alias used by the waveform family exports.
PropbarWidth
Typenumber
Default—
DescriptionFixed bar width in pixels.
PropbarHeight
Typenumber
Default—
DescriptionMinimum bar height in pixels.
Propgap
Typenumber
Default1
DescriptionGap between bars in pixels.
PropbarGap
Typenumber
Default1
DescriptionUpstream alias for gap between bars in pixels.
PropbarRadius
Typenumber
Default1
DescriptionBar corner radius.
PropfadeEdges
Typeboolean
Defaultfalse
DescriptionFade the waveform edges for a softer visual.
PropfadeWidth
Typenumber
Default24
DescriptionFade width in pixels when edge fading is enabled.
Propheight
Typenumber | string
Default—
DescriptionExplicit height override for the waveform container.
ProponSeek
Type(position: number) => void
Default—
DescriptionCalled on click with seek position (0–1).
Propsize
Type"sm" | "md" | "lg"
Default"md"
DescriptionHeight variant.
PropTypeDefaultDescription
dataFloat32Array | number[]—Waveform amplitude data (values -1 to 1).
barsnumber100Number of bars to render.
progressnumber0Playback progress (0–1).
playedColorstringprimaryColor of played portion bars.
unplayedColorstringmutedColor of unplayed portion bars.
barColorstring—Shared bar color alias used by the waveform family exports.
barWidthnumber—Fixed bar width in pixels.
barHeightnumber—Minimum bar height in pixels.
gapnumber1Gap between bars in pixels.
barGapnumber1Upstream alias for gap between bars in pixels.
barRadiusnumber1Bar corner radius.
fadeEdgesbooleanfalseFade the waveform edges for a softer visual.
fadeWidthnumber24Fade width in pixels when edge fading is enabled.
heightnumber | string—Explicit height override for the waveform container.
onSeek(position: number) => void—Called on click with seek position (0–1).
size"sm" | "md" | "lg""md"Height variant.

AudioRecorder

Recording component with timer, pause/resume, and audio level meter. Uses MediaRecorder API.

RecorderState type

"idle" | "recording" | "paused" | "stopped"

ProponRecordingComplete
Type(blob: Blob, url: string) => void
Default—
DescriptionCalled when recording finishes with the audio Blob and object URL.
ProponStateChange
Type(state: RecorderState) => void
Default—
DescriptionCalled when the recorder state changes.
ProponError
Type(error: string) => void
Default—
DescriptionCalled on recording errors.
PropmaxDuration
Typenumber
Default300
DescriptionMaximum recording duration in seconds (5 minutes).
PropmimeType
Typestring
Defaultauto-detected
DescriptionPreferred MIME type for the recording.
PropshowTimer
Typeboolean
Defaulttrue
DescriptionShow the elapsed time display.
PropshowLevel
Typeboolean
Defaulttrue
DescriptionShow the audio level meter.
Propsize
Type"sm" | "md" | "lg"
Default"md"
DescriptionSize variant.
PropTypeDefaultDescription
onRecordingComplete(blob: Blob, url: string) => void—Called when recording finishes with the audio Blob and object URL.
onStateChange(state: RecorderState) => void—Called when the recorder state changes.
onError(error: string) => void—Called on recording errors.
maxDurationnumber300Maximum recording duration in seconds (5 minutes).
mimeTypestringauto-detectedPreferred MIME type for the recording.
showTimerbooleantrueShow the elapsed time display.
showLevelbooleantrueShow the audio level meter.
size"sm" | "md" | "lg""md"Size variant.

MicSelector

Microphone device picker with permission request handling and mute toggle.

Propvalue
Typestring
Default—
DescriptionSelected device ID (controlled).
ProponValueChange
Type(deviceId: string) => void
Default—
DescriptionCalled when a device is selected.
Propmuted
Typeboolean
Default—
DescriptionWhether the mic is muted.
ProponMutedChange
Type(muted: boolean) => void
Default—
DescriptionCalled when mute state changes.
Propdisabled
Typeboolean
Default—
DescriptionDisable the selector.
PropTypeDefaultDescription
valuestring—Selected device ID (controlled).
onValueChange(deviceId: string) => void—Called when a device is selected.
mutedboolean—Whether the mic is muted.
onMutedChange(muted: boolean) => void—Called when mute state changes.
disabledboolean—Disable the selector.

VoiceButton

Multi-state voice interaction button with embedded waveform visualization.

VoiceButtonState type

"idle" | "recording" | "processing" | "success" | "error"

Propstate
TypeVoiceButtonState
Default"idle"
DescriptionButton state controlling visual appearance.
ProponPress
Type() => void
Default—
DescriptionCalled when the button is pressed.
Proplabel
TypeReactNode
Default—
DescriptionButton label text.
Proptrailing
TypeReactNode
Default—
DescriptionContent rendered after the label.
Propicon
TypeReactNode
Default—
DescriptionCustom icon element.
Propvariant
Type"default" | "destructive" | "outline" | "secondary" | "ghost" | "link"
Default"outline"
DescriptionVisual variant.
Propsize
Type"default" | "sm" | "lg" | "icon"
Default"default"
DescriptionButton size.
PropwaveformClassName
Typestring
Default—
DescriptionCSS class for the inline waveform.
PropfeedbackDuration
Typenumber
Default1500
DescriptionDuration of success/error feedback animation in ms.
PropTypeDefaultDescription
stateVoiceButtonState"idle"Button state controlling visual appearance.
onPress() => void—Called when the button is pressed.
labelReactNode—Button label text.
trailingReactNode—Content rendered after the label.
iconReactNode—Custom icon element.
variant"default" | "destructive" | "outline" | "secondary" | "ghost" | "link""outline"Visual variant.
size"default" | "sm" | "lg" | "icon""default"Button size.
waveformClassNamestring—CSS class for the inline waveform.
feedbackDurationnumber1500Duration of success/error feedback animation in ms.

Display & Interaction

Matrix

SVG dot-matrix display with animation frames and preset patterns. Supports VU meter mode for audio levels.

Presets

Built-in patterns: digits, chevronLeft, chevronRight, loader, pulse, wave, snake. Utility: vu(columns, levels) generates VU meter frames.

Proprows
Typenumber
Default—
DescriptionNumber of dot rows (required).
Propcols
Typenumber
Default—
DescriptionNumber of dot columns (required).
Proppattern
TypeFrame
Default—
DescriptionStatic frame pattern (number[][]).
Propframes
TypeFrame[]
Default—
DescriptionAnimation frames array.
Propfps
Typenumber
Default12
DescriptionAnimation frames per second.
Propautoplay
Typeboolean
Defaulttrue
DescriptionAutomatically play the animation.
Proploop
Typeboolean
Defaulttrue
DescriptionLoop the animation.
Propsize
Typenumber
Default10
DescriptionPixel dot size.
Propgap
Typenumber
Default2
DescriptionGap between dots.
Proppalette
Type{ on: string; off: string }
Default{ on: "currentColor", off: "var(--muted-foreground)" }
DescriptionDot colors.
Propbrightness
Typenumber
Default1
DescriptionBase brightness multiplier for dots.
PropariaLabel
Typestring
Default—
DescriptionAccessible aria-label for the matrix.
ProponFrame
Type(index: number) => void
Default—
DescriptionCalled on each frame advance with the frame index.
Propmode
Type"default" | "vu"
Default"default"
DescriptionDisplay mode — "vu" enables level meters.
Proplevels
Typenumber[]
Default—
DescriptionVU meter levels (for mode="vu").
PropTypeDefaultDescription
rowsnumber—Number of dot rows (required).
colsnumber—Number of dot columns (required).
patternFrame—Static frame pattern (number[][]).
framesFrame[]—Animation frames array.
fpsnumber12Animation frames per second.
autoplaybooleantrueAutomatically play the animation.
loopbooleantrueLoop the animation.
sizenumber10Pixel dot size.
gapnumber2Gap between dots.
palette{ on: string; off: string }{ on: "currentColor", off: "var(--muted-foreground)" }Dot colors.
brightnessnumber1Base brightness multiplier for dots.
ariaLabelstring—Accessible aria-label for the matrix.
onFrame(index: number) => void—Called on each frame advance with the frame index.
mode"default" | "vu""default"Display mode — "vu" enables level meters.
levelsnumber[]—VU meter levels (for mode="vu").

ShimmeringText

Animated gradient shimmer text effect with viewport-triggered animation using motion/react.

Proptext
Typestring
Default—
DescriptionText to render with shimmer effect (required).
Propduration
Typenumber
Default2
DescriptionAnimation duration in seconds.
Propdelay
Typenumber
Default0
DescriptionAnimation delay in seconds.
Proprepeat
Typeboolean
Defaulttrue
DescriptionWhether the animation repeats.
Propspread
Typenumber
Default2
DescriptionShimmer gradient spread.
Propcolor
Typestring
Default—
DescriptionBase text color.
PropshimmerColor
Typestring
Default—
DescriptionShimmer highlight color.
PropstartOnView
Typeboolean
Defaulttrue
DescriptionStart animation when element enters viewport.
Proponce
Typeboolean
Defaultfalse
DescriptionPlay the animation only once.
ProprepeatDelay
Typenumber
Default0.5
DescriptionDelay between animation repeats in seconds.
PropTypeDefaultDescription
textstring—Text to render with shimmer effect (required).
durationnumber2Animation duration in seconds.
delaynumber0Animation delay in seconds.
repeatbooleantrueWhether the animation repeats.
spreadnumber2Shimmer gradient spread.
colorstring—Base text color.
shimmerColorstring—Shimmer highlight color.
startOnViewbooleantrueStart animation when element enters viewport.
oncebooleanfalsePlay the animation only once.
repeatDelaynumber0.5Delay between animation repeats in seconds.

CodeBlock

Syntax-highlighted code block with Shiki, copy button, optional line numbers, and language badge.

Propcode
Typestring
Default—
DescriptionCode string to display (required).
Proplanguage
Typestring
Default"tsx"
DescriptionProgramming language for syntax highlighting.
PropshowLineNumbers
Typeboolean
Defaultfalse
DescriptionShow line numbers.
PropshowCopy
Typeboolean
Defaulttrue
DescriptionShow copy-to-clipboard button.
Proptitle
Typestring
Default—
DescriptionOptional title/filename displayed at the top.
PropmaxHeight
Typenumber | string
Default—
DescriptionMaximum height before scrolling.
Propsize
Type"sm" | "md" | "lg"
Default"md"
DescriptionSize variant.
PropTypeDefaultDescription
codestring—Code string to display (required).
languagestring"tsx"Programming language for syntax highlighting.
showLineNumbersbooleanfalseShow line numbers.
showCopybooleantrueShow copy-to-clipboard button.
titlestring—Optional title/filename displayed at the top.
maxHeightnumber | string—Maximum height before scrolling.
size"sm" | "md" | "lg""md"Size variant.

SpeechInput

Web Speech API powered speech-to-text input. Supports continuous mode, interim results, and custom rendering via children render prop.

SpeechInputState type

"idle" | "listening" | "processing" | "error" | "unsupported"

ProponTranscript
Type(text: string, isFinal: boolean) => void
Default—
DescriptionCalled with transcript text and finality flag.
ProponError
Type(error: string) => void
Default—
DescriptionCalled on speech recognition errors.
ProponStateChange
Type(state: SpeechInputState) => void
Default—
DescriptionCalled when recognition state changes.
Proplang
Typestring
Default"en-US"
DescriptionBCP-47 language tag.
Propcontinuous
Typeboolean
Defaultfalse
DescriptionKeep listening after pauses.
PropinterimResults
Typeboolean
Defaulttrue
DescriptionReturn partial results while speaking.
Propchildren
Type(state, toggle) => ReactNode
Default—
DescriptionRender prop for custom UI.
PropTypeDefaultDescription
onTranscript(text: string, isFinal: boolean) => void—Called with transcript text and finality flag.
onError(error: string) => void—Called on speech recognition errors.
onStateChange(state: SpeechInputState) => void—Called when recognition state changes.
langstring"en-US"BCP-47 language tag.
continuousbooleanfalseKeep listening after pauses.
interimResultsbooleantrueReturn partial results while speaking.
children(state, toggle) => ReactNode—Render prop for custom UI.

ConversationBar

Text input bar with send button and connection toggle for real-time voice/chat sessions.

AgentConnectionState type

"disconnected" | "connecting" | "connected" | "disconnecting"

ProponSend
Type(message: string) => void
Default—
DescriptionCalled when a message is sent.
ProponConnect
Type() => void
Default—
DescriptionCalled when connect button is clicked.
ProponDisconnect
Type() => void
Default—
DescriptionCalled when disconnect button is clicked.
PropconnectionState
TypeAgentConnectionState
Default"disconnected"
DescriptionCurrent connection state.
Propplaceholder
Typestring
Default"Type a message…"
DescriptionInput placeholder text.
PropshowConnectionToggle
Typeboolean
Defaulttrue
DescriptionShow the connection toggle button.
PropisSendDisabled
Typeboolean
Defaultfalse
DescriptionDisable the send button.
PropTypeDefaultDescription
onSend(message: string) => void—Called when a message is sent.
onConnect() => void—Called when connect button is clicked.
onDisconnect() => void—Called when disconnect button is clicked.
connectionStateAgentConnectionState"disconnected"Current connection state.
placeholderstring"Type a message…"Input placeholder text.
showConnectionTogglebooleantrueShow the connection toggle button.
isSendDisabledbooleanfalseDisable the send button.

TranscriptViewer

Compound transcript display with per-character highlighting, auto-scroll, and synchronized audio playback.

Propalignment
TypeCharacterAlignmentResponseModel
Default—
DescriptionCharacter-level timing alignment data.
Proptext
Typestring
Default—
DescriptionFallback transcript text when alignment timing data is unavailable.
PropaudioSrc
Typestring
Default—
DescriptionAudio source URL for synchronized playback.
Propsrc
Typestring
Default—
DescriptionBackward-compatible alias for audioSrc.
PropaudioType
Typestring
Default"audio/mpeg"
DescriptionMIME type applied to the generated source element.
PropsegmentComposer
Type(alignment) => { segments; words }
Default—
DescriptionCustom function to compose alignment data into transcript segments and words.
Propcomposer
Type(alignment) => AlignmentCharacter[]
Default—
DescriptionLower-level compatibility hook for custom character composition before segment building.
ProphideAudioTags
Typeboolean
Defaulttrue
DescriptionHide bracketed audio tags like [laughs] when composing transcript words.
ProponPlay
Type() => void
Default—
DescriptionCalled when synchronized audio playback starts.
ProponPause
Type() => void
Default—
DescriptionCalled when synchronized audio playback pauses.
ProponTimeUpdate
Type(time: number) => void
Default—
DescriptionCalled during audio playback with current time.
ProponEnded
Type() => void
Default—
DescriptionCalled when synchronized audio playback finishes.
ProponDurationChange
Type(duration: number) => void
Default—
DescriptionCalled when the audio duration becomes available or changes.
PropTypeDefaultDescription
alignmentCharacterAlignmentResponseModel—Character-level timing alignment data.
textstring—Fallback transcript text when alignment timing data is unavailable.
audioSrcstring—Audio source URL for synchronized playback.
srcstring—Backward-compatible alias for audioSrc.
audioTypestring"audio/mpeg"MIME type applied to the generated source element.
segmentComposer(alignment) => { segments; words }—Custom function to compose alignment data into transcript segments and words.
composer(alignment) => AlignmentCharacter[]—Lower-level compatibility hook for custom character composition before segment building.
hideAudioTagsbooleantrueHide bracketed audio tags like [laughs] when composing transcript words.
onPlay() => void—Called when synchronized audio playback starts.
onPause() => void—Called when synchronized audio playback pauses.
onTimeUpdate(time: number) => void—Called during audio playback with current time.
onEnded() => void—Called when synchronized audio playback finishes.
onDurationChange(duration: number) => void—Called when the audio duration becomes available or changes.

Sub-components: TranscriptViewerWords, TranscriptViewerWord, TranscriptViewerAudio, TranscriptViewerPlayPauseButton, TranscriptViewerScrubBar, and the exported hook useTranscriptViewerContext

Rich sub-component props: TranscriptViewerWords supports renderWord, renderGap, wordClassNames, and gapClassNames. TranscriptViewerScrubBar supports showTimeLabels, labelsClassName, trackClassName, progressClassName, and thumbClassName.

VoicePicker

Selectable voice list with labels, descriptions, and audio preview playback.

Voice type

{ voiceId: string; name: string; previewUrl?: string; labels?: Record<string, string>; description?: string; category?: string }

Propvoices
TypeVoice[]
Default—
DescriptionArray of voice objects to display (required).
Propvalue
Typestring
Default—
DescriptionSelected voice ID (controlled).
ProponValueChange
Type(voiceId: string) => void
Default—
DescriptionCalled when a voice is selected.
Propplaceholder
Typestring
Default"Select a voice…"
DescriptionPlaceholder text when no voice is selected.
Propopen
Typeboolean
Default—
DescriptionControlled open state.
ProponOpenChange
Type(open: boolean) => void
Default—
DescriptionCalled when the picker opens or closes.
PropTypeDefaultDescription
voicesVoice[]—Array of voice objects to display (required).
valuestring—Selected voice ID (controlled).
onValueChange(voiceId: string) => void—Called when a voice is selected.
placeholderstring"Select a voice…"Placeholder text when no voice is selected.
openboolean—Controlled open state.
onOpenChange(open: boolean) => void—Called when the picker opens or closes.

Orb

Self-contained canvas orb with organic state motion, glow, pulse rings, and no WebGL or remote texture dependency.

AgentState type

"idle" | "thinking" | "listening" | "talking"

Propcolors
Type[string, string]
Default["#CADCFC", "#A0B9D1"]
DescriptionGradient color pair for the orb.
Propseed
Typenumber
Default42
DescriptionRNG seed for noise generation.
PropagentState
Type"idle" | "thinking" | "listening" | "talking"
Default"idle"
DescriptionAgent state controlling motion and pulse behavior.
PropvolumeMode
Type"auto" | "manual"
Default"auto"
DescriptionVolume input mode.
PropmanualInput
Typenumber
Default—
DescriptionManual input volume (0–1).
PropmanualOutput
Typenumber
Default—
DescriptionManual output volume (0–1).
PropcolorsRef
TypeRefObject<[string, string]>
Default—
DescriptionRef-based color pair for frame-sync updates.
PropinputVolumeRef
TypeRefObject<number>
Default—
DescriptionRef-based input volume (avoids re-renders).
PropoutputVolumeRef
TypeRefObject<number>
Default—
DescriptionRef-based output volume (avoids re-renders).
PropgetInputVolume
Type() => number
Default—
DescriptionGetter function for input volume.
PropgetOutputVolume
Type() => number
Default—
DescriptionGetter function for output volume.
Propintensity
Typenumber
Default1
DescriptionOrganic deformation intensity.
PropclassName
Typestring
Default—
DescriptionAdditional CSS classes for the orb container.
PropTypeDefaultDescription
colors[string, string]["#CADCFC", "#A0B9D1"]Gradient color pair for the orb.
seednumber42RNG seed for noise generation.
agentState"idle" | "thinking" | "listening" | "talking""idle"Agent state controlling motion and pulse behavior.
volumeMode"auto" | "manual""auto"Volume input mode.
manualInputnumber—Manual input volume (0–1).
manualOutputnumber—Manual output volume (0–1).
colorsRefRefObject<[string, string]>—Ref-based color pair for frame-sync updates.
inputVolumeRefRefObject<number>—Ref-based input volume (avoids re-renders).
outputVolumeRefRefObject<number>—Ref-based output volume (avoids re-renders).
getInputVolume() => number—Getter function for input volume.
getOutputVolume() => number—Getter function for output volume.
intensitynumber1Organic deformation intensity.
classNamestring—Additional CSS classes for the orb container.

Hooks

useAudioPlayer

Standalone hook for controlling audio playback with play, pause, seek, volume, and speed. Returns state and actions.

example.tsx
15 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { useAudioPlayer } from "@/hooks/use-audio-player";

function CustomPlayer() {
  const { isPlaying, currentTime, duration, toggle, seek } = useAudioPlayer({
    src: "/audio/track.mp3",
    onEnded: () => console.log("Track ended"),
  });

  return (
    <div>
      <button onClick={toggle}>{isPlaying ? "Pause" : "Play"}</button>
      <span>{currentTime.toFixed(1)}s / {duration.toFixed(1)}s</span>
    </div>
  );
}
PropertyisPlaying
Typeboolean
DescriptionWhether audio is currently playing.
PropertycurrentTime
Typenumber
DescriptionCurrent playback time in seconds.
Propertyduration
Typenumber
DescriptionTotal audio duration in seconds.
Propertyvolume
Typenumber
DescriptionCurrent volume (0–1).
PropertyisMuted
Typeboolean
DescriptionWhether audio is muted.
PropertyplaybackRate
Typenumber
DescriptionCurrent playback speed.
PropertyisBuffering
Typeboolean
DescriptionWhether audio is buffering.
Propertyerror
Typestring | null
DescriptionError message, if any.
Propertyplay()
Type() => void
DescriptionStart playback.
Propertypause()
Type() => void
DescriptionPause playback.
Propertytoggle()
Type() => void
DescriptionToggle play/pause.
Propertyseek(time)
Type(time: number) => void
DescriptionSeek to a specific time in seconds.
PropertysetVolume(vol)
Type(volume: number) => void
DescriptionSet volume (0–1).
PropertytoggleMute()
Type() => void
DescriptionToggle mute state.
PropertysetPlaybackRate(rate)
Type(rate: number) => void
DescriptionSet playback speed.
Propertyload(src)
Type(src: string) => void
DescriptionLoad a new audio source.
PropertyhasEnded
Typeboolean
DescriptionWhether the audio has reached the end.
PropertyaudioRef
TypeRefObject<HTMLAudioElement | null>
DescriptionRef to the underlying audio element.
PropertyTypeDescription
isPlayingbooleanWhether audio is currently playing.
currentTimenumberCurrent playback time in seconds.
durationnumberTotal audio duration in seconds.
volumenumberCurrent volume (0–1).
isMutedbooleanWhether audio is muted.
playbackRatenumberCurrent playback speed.
isBufferingbooleanWhether audio is buffering.
errorstring | nullError message, if any.
play()() => voidStart playback.
pause()() => voidPause playback.
toggle()() => voidToggle play/pause.
seek(time)(time: number) => voidSeek to a specific time in seconds.
setVolume(vol)(volume: number) => voidSet volume (0–1).
toggleMute()() => voidToggle mute state.
setPlaybackRate(rate)(rate: number) => voidSet playback speed.
load(src)(src: string) => voidLoad a new audio source.
hasEndedbooleanWhether the audio has reached the end.
audioRefRefObject<HTMLAudioElement | null>Ref to the underlying audio element.

useAudioVolume

Tracks real-time volume/frequency data from a MediaStream using Web Audio API AnalyserNode.

example.tsx
8 lines
1
2
3
4
5
6
7
8
import { useAudioVolume } from "@/hooks/use-audio-volume";

function VolumeMeter({ stream }: { stream: MediaStream | null }) {
  const { data, isActive } = useAudioVolume({ stream, frequencyMode: true });

  // data is a Uint8Array of frequency values (0–255)
  return <div>{isActive ? "Listening..." : "Idle"}</div>;
}
Propertydata
TypeUint8Array | null
DescriptionRaw frequency/time-domain data from the analyser.
Propertyanalyser
TypeAnalyserNode | null
DescriptionWeb Audio API analyser node.
PropertyisActive
Typeboolean
DescriptionWhether the analyser is active.
Propertyerror
Typestring | null
DescriptionError message, if any.
PropertyTypeDescription
dataUint8Array | nullRaw frequency/time-domain data from the analyser.
analyserAnalyserNode | nullWeb Audio API analyser node.
isActivebooleanWhether the analyser is active.
errorstring | nullError message, if any.

useAudioDevices

Enumerates audio input devices with permission handling, device selection, and stream management.

example.tsx
18 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { useAudioDevices } from "@/hooks/use-audio-devices";

function DevicePicker() {
  const { devices, hasPermission, requestPermission, selectDevice } =
    useAudioDevices({ kind: "audioinput" });

  if (!hasPermission) {
    return <button onClick={requestPermission}>Allow Microphone</button>;
  }

  return (
    <select onChange={(e) => selectDevice(e.target.value)}>
      {devices.map((d) => (
        <option key={d.deviceId} value={d.deviceId}>{d.label}</option>
      ))}
    </select>
  );
}
Propertydevices
TypeAudioDevice[]
DescriptionList of available audio devices.
PropertyactiveDeviceId
Typestring | null
DescriptionCurrently active device ID.
Propertystream
TypeMediaStream | null
DescriptionActive media stream.
PropertyhasPermission
Typeboolean
DescriptionWhether microphone permission has been granted.
PropertyisRequesting
Typeboolean
DescriptionWhether permission is being requested.
Propertyerror
Typestring | null
DescriptionError message, if any.
PropertyrequestPermission()
Type() => Promise<void>
DescriptionRequest microphone permission.
PropertyselectDevice(id)
Type(deviceId: string) => Promise<void>
DescriptionSwitch to a specific audio device.
PropertystopStream()
Type() => void
DescriptionStop the active media stream.
PropertyTypeDescription
devicesAudioDevice[]List of available audio devices.
activeDeviceIdstring | nullCurrently active device ID.
streamMediaStream | nullActive media stream.
hasPermissionbooleanWhether microphone permission has been granted.
isRequestingbooleanWhether permission is being requested.
errorstring | nullError message, if any.
requestPermission()() => Promise<void>Request microphone permission.
selectDevice(id)(deviceId: string) => Promise<void>Switch to a specific audio device.
stopStream()() => voidStop the active media stream.

useMultibandVolume

Splits raw frequency data into configurable bands for equalizer-style visualization.

useMultibandVolume(data: Uint8Array | null, { bands?: number, minThreshold?: number })

PropertybandVolumes
Typenumber[]
DescriptionNormalized volume levels (0–1) per frequency band.
PropertyTypeDescription
bandVolumesnumber[]Normalized volume levels (0–1) per frequency band.

useBarAnimator

Provides smooth bar animation with configurable smoothing/decay. Used internally by BarVisualizer.

useBarAnimator({ targetHeights: number[], smoothing?: number, enabled?: boolean })

PropertycurrentHeights
Typenumber[]
DescriptionSmoothly interpolated bar heights.
PropertyTypeDescription
currentHeightsnumber[]Smoothly interpolated bar heights.

Shared Types

example.ts
40 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Agent states used by BarVisualizer, Orb
type AgentState = "connecting" | "initializing" | "listening" | "speaking" | "thinking";

// Orb uses a different set
type OrbAgentState = "idle" | "thinking" | "listening" | "talking";

// Voice button states
type VoiceButtonState = "idle" | "recording" | "processing" | "success" | "error";

// Connection states for ConversationBar
type AgentConnectionState = "disconnected" | "connecting" | "connected" | "disconnecting";

// Audio recorder states
type RecorderState = "idle" | "recording" | "paused" | "stopped";

// Speech input states
type SpeechInputState = "idle" | "listening" | "processing" | "error" | "unsupported";

// Feedback values
type FeedbackValue = "positive" | "negative" | null;

// Audio player item (generic)
interface AudioPlayerItem<TData = unknown> {
  id: string | number;
  src: string;
  data?: TData;
}

// Matrix frame
type Frame = number[][];

// Voice picker voice
interface Voice {
  voiceId: string;
  name: string;
  previewUrl?: string;
  labels?: Record<string, string | undefined>;
  description?: string;
  category?: string;
}