VoiceVisualizer component visualizes audio recording and playback with a customizable waveform display. It provides a complete UI with built-in controls or can be used headlessly with custom controls.
Import
Basic Usage
Props
Required Props
Provides the audio recording controls and states required for visualization. This object is returned from the
useVoiceVisualizer hook.See the useVoiceVisualizer reference for details on the Controls object.Dimension Props
The height of the visualization canvas. Can be specified as a number (pixels) or string with units (e.g., “200px”, “50%”).
The width of the visualization canvas. Can be specified as a number (pixels) or string with units (e.g., “400px”, “100%”).
Color Props
The background color of the visualization canvas. Accepts any valid CSS color value.
The color of the main audio wave bars. This color is used for the active/played portion of the waveform.
The secondary color of the audio wave bars. This color is used for the inactive/unplayed portion of the waveform.
The color of the default microphone icon shown before recording starts. Defaults to the same value as
mainBarColor.The color of the default audio wave icons shown before recording starts. Defaults to the same value as
mainBarColor.Waveform Visualization Props
The width of each audio wave bar in pixels. Integer value.
The gap between each audio wave bar. Integer value.
The border radius of the audio wave bars in pixels.
The speed of the audio visualization animation. Integer from 1 to 6, where a higher number results in slower animation.
Whether to animate the current bar being recorded in the visualization.
Whether the visualization should be displayed in fullscreen mode. When enabled, the waveform begins from the center and extends outward.
Control Panel Props
Whether to display the audio control panel, including features such as recorded audio duration, current recording time, and control buttons.If you want to create your own UI, set this to
false and utilize functions from the useVoiceVisualizer hook to manage audio control.Whether to display the Download audio button in the control panel.
Behavior Props
Whether to show the visualization only during voice recording. When set to
true, the waveform is cleared after recording stops.Whether to show a default UI on the canvas before recording starts (microphone icon and audio wave icons).If you want to create your own UI, set this to
false.Progress Indicator Props
Whether to show the progress indicator after recording. Automatically set to
false when onlyRecording is true.Whether to show the time label on the progress indicator.
Whether to show the hover progress indicator when hovering over the recorded audio waveform. Automatically set to
false when onlyRecording is true.Whether to show the time label on the hover progress indicator.
Whether to show the “Processing Audio…” text while audio is being processed.
Custom Styling Props
Custom CSS class name for the main container element.
Custom CSS class name for the container of the visualization canvas.
Custom CSS class name for the progress indicator.
Custom CSS class name for the progress indicator time label.
Custom CSS class name for the progress indicator shown on hover.
Custom CSS class name for the progress indicator time label shown on hover.
Custom CSS class name for the “Processing Audio…” text.
Custom CSS class name for the Clear Button and Download Audio button components.
Examples
Minimal Setup
Custom Colors and Dimensions
Recording Only Mode
Custom Controls with Hidden Default UI
Custom CSS Classes
custom-audio-styles.css
Fullscreen Visualization
With Download Button
Visual Effects
Bar Width and Gap
ThebarWidth and gap props control the density of the waveform:
- Smaller values (e.g.,
barWidth={1},gap={0}) create a denser, more detailed waveform - Larger values (e.g.,
barWidth={4},gap={3}) create a sparser, more stylized look
Animation Speed
Thespeed prop affects how frequently the visualization updates:
speed={1}- Updates every frame (fastest)speed={3}- Updates every 3 frames (default, balanced)speed={6}- Updates every 6 frames (slowest, least resource-intensive)
Rounded Corners
Therounded prop applies border-radius to each bar:
rounded={0}- Sharp rectangular barsrounded={5}- Slightly rounded (default)rounded={10}- Very rounded, pill-shaped bars
Styling with CSS Classes
AllclassName props accept custom CSS classes that will be applied to their respective elements. This allows you to:
- Override default styles
- Add custom animations
- Integrate with CSS frameworks like Tailwind CSS
- Apply responsive styles with media queries
See Also
- useVoiceVisualizer Hook - Hook that provides the controls
- Types - TypeScript interface definitions
- Customization Guide - Advanced styling techniques
- Custom UI Guide - Building custom UI controls

