TrackToggle
function TrackToggle<T>(__namedParameters): Element;Defined in: packages/react/src/components/track/TrackToggle.tsx:64
With the TrackToggle component it is possible to mute and unmute your camera and microphone. The component uses an html button element under the hood so you can treat it like a button.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | ToggleSource |
Parameters
| Parameter | Type |
|---|---|
__namedParameters | TrackToggleProps<T> |
Returns
Element
Example
// Basic — toggle microphone and camera publishing.
<VoiceRoom agent={agent}>
<TrackToggle source={Track.Source.Microphone} />
<TrackToggle source={Track.Source.Camera} />
</VoiceRoom>
// Advanced — react to user-initiated mute changes.
<VoiceRoom agent={agent}>
<div className="call-controls">
<TrackToggle
source="microphone"
initialEnabled
onChange={(enabled, isUserInitiated) => {
if (isUserInitiated) logMicChange(enabled);
}}
/>
<StartAudio label="Enable audio" />
</div>
</VoiceRoom>