Usage
Code
'use client';import { useSession } from '@livekit/components-react';import { AgentSessionProvider } from '@/components/agents-ui/agent-session-provider';import { AgentControlBar } from '@/components/agents-ui/agent-control-bar';const TOKEN_SOURCE = TokenSource.sandboxTokenServer(process.env.MY_LK_SANDBOX_TOKEN_SERVER_ID);export function Demo() {const session = useSession(TOKEN_SOURCE);return (<AgentSessionProvider session={session}><AgentControlBarvariant="livekit"isChatOpen=falseisConnected=truecontrols={"leave":true,"microphone":true,"screenShare":true,"camera":true,"chat":true}/></AgentSessionProvider>);}
Features
- Configure which
controlsare visible:leave,microphone,camera,screenShare, andchat - Three style
variantoptions:default,outline, andlivekit - Chat input visibility can be controlled (
isChatOpen+onIsChatOpenChange) or uncontrolled - Persist user device preferences with
saveUserChoices(enabled by default) - Handle device errors with the
onDeviceErrorcallback - Disconnect button state controlled by
isConnected
Installation
pnpm dlx shadcn@latest add @agents-ui/agent-control-bar
Props
| Prop name | Type | Default |
|---|---|---|
variant? | enum | default |
controls? | AgentControlBarControls |
|
saveUserChoices? | boolean | true |
isConnected? | boolean | – |
isChatOpen? | boolean | – |
onDisconnect? | function | – |
onIsChatOpenChange? | function | – |
onDeviceError? | function | – |
ref? | Ref<HTMLDivElement> | – |
...props? | ComponentProps<'div'> | |