Documentation Index Fetch the complete documentation index at: https://cometchat-22654f5b-react-uikit-v7.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
AI Integration Quick Reference
{
"component" : "CometChatMediaRecorder" ,
"package" : "@cometchat/chat-uikit-react" ,
"import" : "import { CometChatMediaRecorder } from \" @cometchat/chat-uikit-react \" ;" ,
"cssImport" : "import \" @cometchat/chat-uikit-react/css-variables.css \" ;" ,
"description" : "Inline audio recording component for the message composer with real-time waveform visualization." ,
"cssRootClass" : ".cometchat-media-recorder--inline" ,
"primaryOutput" : {
"prop" : "onSubmit" ,
"type" : "(file: Blob) => void"
},
"props" : {
"behavior" : {
"autoRecording" : { "type" : "boolean" , "default" : "false" }
},
"callbacks" : {
"onClose" : { "type" : "() => void" , "default" : "undefined" },
"onSubmit" : { "type" : "(file: Blob) => void" , "default" : "undefined" },
"onError" : { "type" : "(error: Error) => void" , "default" : "undefined" }
}
},
"subComponents" : [
"CometChatMediaRecorder.Root" ,
"CometChatMediaRecorder.RecordingView" ,
"CometChatMediaRecorder.PreviewView" ,
"CometChatMediaRecorder.Timer" ,
"CometChatMediaRecorder.Controls" ,
"CometChatMediaRecorder.ErrorView"
],
"types" : {
"CometChatMediaRecorderState" : "'idle' | 'recording' | 'paused' | 'error'"
}
}
Where It Fits
CometChatMediaRecorder is an inline base component rendered inside the message composer for recording voice messages. It displays as a horizontal bar with delete, waveform visualization, timer, and recording controls. The composer’s send button calls inlineSend() from context to stop recording and submit the audio blob.
import { CometChatMediaRecorder } from "@cometchat/chat-uikit-react" ;
import "@cometchat/chat-uikit-react/css-variables.css" ;
function VoiceRecorder ({ onClose , onSubmit } : {
onClose : () => void ;
onSubmit : ( blob : Blob ) => void ;
}) {
return (
< CometChatMediaRecorder.Root onClose = { onClose } onSubmit = { onSubmit } >
< CometChatMediaRecorder.ErrorView />
< CometChatMediaRecorder.Controls />
< CometChatMediaRecorder.RecordingView >
< CometChatMediaRecorder.Timer />
</ CometChatMediaRecorder.RecordingView >
< CometChatMediaRecorder.PreviewView >
< CometChatMediaRecorder.Timer />
</ CometChatMediaRecorder.PreviewView >
</ CometChatMediaRecorder.Root >
);
}
Minimal Render
import { CometChatMediaRecorder } from "@cometchat/chat-uikit-react" ;
import "@cometchat/chat-uikit-react/css-variables.css" ;
function Demo () {
return (
< CometChatMediaRecorder.Root >
< CometChatMediaRecorder.ErrorView />
< CometChatMediaRecorder.Controls />
< CometChatMediaRecorder.RecordingView >
< CometChatMediaRecorder.Timer />
</ CometChatMediaRecorder.RecordingView >
< CometChatMediaRecorder.PreviewView >
< CometChatMediaRecorder.Timer />
</ CometChatMediaRecorder.PreviewView >
</ CometChatMediaRecorder.Root >
);
}
Root CSS class: .cometchat-media-recorder--inline
Actions and Events
Callback Props
onSubmit
Called when the composer’s send button triggers inlineSend(). Receives the recorded audio as a Blob.
< CometChatMediaRecorder.Root
onSubmit = { ( blob ) => {
const file = new File ([ blob ], "voice-message.webm" , { type: blob . type });
sendMessage ( file );
} }
>
{ /* sub-components */ }
</ CometChatMediaRecorder.Root >
onClose
Called when the user deletes/cancels the recording.
< CometChatMediaRecorder.Root
onClose = { () => setShowRecorder ( false ) }
>
{ /* sub-components */ }
</ CometChatMediaRecorder.Root >
onError
Called when a recording error occurs (permission denied, device unavailable).
< CometChatMediaRecorder.Root
onError = { ( error ) => console . error ( 'Recording error:' , error ) }
>
{ /* sub-components */ }
</ CometChatMediaRecorder.Root >
Common Patterns
Auto-start recording on mount
< CometChatMediaRecorder.Root autoRecording onClose = { onClose } onSubmit = { onSubmit } >
< CometChatMediaRecorder.ErrorView />
< CometChatMediaRecorder.Controls />
< CometChatMediaRecorder.RecordingView >
< CometChatMediaRecorder.Timer />
</ CometChatMediaRecorder.RecordingView >
< CometChatMediaRecorder.PreviewView >
< CometChatMediaRecorder.Timer />
</ CometChatMediaRecorder.PreviewView >
</ CometChatMediaRecorder.Root >
Inline send from composer
The composer’s send button can call inlineSend() from context to stop recording and immediately submit:
import { useCometChatMediaRecorderContext } from "@cometchat/chat-uikit-react" ;
function ComposerSendButton () {
const { inlineSend } = useCometChatMediaRecorderContext ();
return < button onClick = { inlineSend } > Send </ button > ;
}
CSS Architecture
The component uses CSS custom properties (design tokens) defined in @cometchat/chat-uikit-react/css-variables.css. Icons use CSS mask images for theme-aware coloring.
Key Selectors
Target Selector Root container .cometchat-media-recorder--inlineDelete button .cometchat-media-recorder__inline-deleteRecord button .cometchat-media-recorder__inline-recordRecording dot .cometchat-media-recorder__recording-dotWaveform .cometchat-media-recorder__waveformWaveform bar .cometchat-media-recorder__waveform-barActive bar .cometchat-media-recorder__waveform-bar--activeTimer .cometchat-media-recorder__timerPause button .cometchat-media-recorder__inline-pauseResume button .cometchat-media-recorder__inline-resumeError view .cometchat-media-recorder__inline-errorClose button .cometchat-media-recorder__inline-close
Customization Matrix
What to change Where Property/API Example Handle submission Root props onSubmit callbackonSubmit={(blob) => send(blob)}Handle close Root props onClose callbackonClose={() => hide()}Handle errors Root props onError callbackonError={(err) => log(err)}Auto-start Root props autoRecordingautoRecording={true}Hide error view Composition Omit ErrorView Don’t render <ErrorView /> Change visual styling Global CSS .cometchat-media-recorder-* selectorsSee CSS selectors table
Props
All props are optional unless noted otherwise.
autoRecording
Start recording immediately when the component mounts.
onClose
Callback invoked when the recording is cancelled or deleted.
Type () => voidDefault undefined
onSubmit
Callback invoked when the recorded audio is submitted. Receives the audio data as a Blob.
Type (file: Blob) => voidDefault undefined
onError
Callback invoked when a recording error occurs.
Type (error: Error) => voidDefault undefined
className
Optional custom CSS class name applied to the root container.
Type stringDefault undefined
CSS Selectors
Target Selector Root .cometchat-media-recorder--inlineScreen reader only .cometchat-media-recorder__sr-onlyDelete button .cometchat-media-recorder__inline-deleteDelete icon .cometchat-media-recorder__inline-delete-iconRecording dot .cometchat-media-recorder__recording-dotRecord button .cometchat-media-recorder__inline-recordRecord icon .cometchat-media-recorder__inline-record-iconWaveform container .cometchat-media-recorder__waveformWaveform bar .cometchat-media-recorder__waveform-barActive waveform bar .cometchat-media-recorder__waveform-bar--activeTimer .cometchat-media-recorder__timerPause button .cometchat-media-recorder__inline-pausePause icon .cometchat-media-recorder__inline-pause-iconResume button .cometchat-media-recorder__inline-resumeResume icon .cometchat-media-recorder__inline-resume-iconError container .cometchat-media-recorder__inline-errorError icon .cometchat-media-recorder__inline-error-iconError text .cometchat-media-recorder__inline-error-textClose button .cometchat-media-recorder__inline-closeClose icon .cometchat-media-recorder__inline-close-icon