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.NEXT_PUBLIC_ 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 controls are visible:
microphone,camera,screenShare,chat, andleave - Select from three styles:
default,outline, andlivekit - Control chat input visibility with
isChatOpenandonIsChatOpenChange - Persist user device preferences with
saveUserChoices(enabled by default) - Handle device errors
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'> | |