NoiseSuppressionToggle wraps the SDK's noiseSuppression namespace with an accessible role="switch" control. Optimistic state with revert-on- error; renders a disabled "Not supported" state when the SDK reports the browser can't run the DSP (e.g. Safari < 17).
Install
pnpm add @levelchat/react-components @levelchat/webRequirements
- React —
reactandreact-dom^18 || ^19(peer dependency). - LevelChat Web SDK —
@levelchat/web^0.2.4(peer dependency, wires hook-driven mode to the live Room). - Provider — wrap the tree in
<LevelChatProvider>from@levelchat/web-reactso hook-driven mode can subscribe to room events. Prop-driven demos work without it. - Styles — import the brand tokens + kit stylesheet exactly once at the app entry, before any kit component renders.
In Next.js (App Router), import the stylesheets at the top of your root layout:
// app/layout.tsx
import '@levelchat/brand/tokens.css';
import '@levelchat/react-components/styles.css';In Vite (or any plain React app), import them at the top of your entry module:
// src/main.tsx
import '@levelchat/brand/tokens.css';
import '@levelchat/react-components/styles.css';Basic usage
import { NoiseSuppressionToggle } from '@levelchat/react-components';
<NoiseSuppressionToggle />Capability detection
Never branch on navigator.userAgent here — trust the SDK's supportedflag, which checks the browser's AudioContext + AudioWorkletavailability at runtime. When unsupported, the switch is disabled with aria-describedby pointing at "Not supported in this browser".
Props
| Prop | Type | Default | Notes |
|---|---|---|---|
renderLabel | (state) => ReactNode | "Noise suppression" | Override the label (i18n). |
hideStatus | boolean | false | Hide the descriptive text under the switch. |