Skip to main content

AgentPanel

AgentPanel wraps AgentChat in a fixed-position slide-in drawer. Use it when you want a side panel that opens and closes without building the layout yourself.

Usage

import { useState } from 'react';
import { AgentProvider, AgentPanel } from '@kapaai/agent-react';

function App() {
const [open, setOpen] = useState(false);

return (
<AgentProvider {...agentConfig}>
<button onClick={() => setOpen(true)}>Open Agent</button>

<AgentPanel
open={open}
onClose={() => setOpen(false)}
width={480}
top={60}
branding={{
title: 'Support Agent',
}}
/>
</AgentProvider>
);
}

Props

All AgentChat props are supported and passed through. Additional panel-specific props:

PropTypeDefaultDescription
openbooleanWhether the panel is visible.
onClose() => voidCalled when the user clicks the close button. Also passed to AgentChat.
widthnumber476Panel width in pixels.
topnumber | string0CSS top offset. Use this when your page has a fixed navbar (e.g. top={60} or top="var(--navbar-height)").
brandingAgentChatBrandingPassed through to AgentChat.
headerActionsReactNodePassed through to AgentChat.
maxContentWidthnumber820Passed through to AgentChat.

When to use AgentChat vs AgentPanel

Use caseComponent
Chat embedded in the page (fills a container)AgentChat
Slide-in drawer from the rightAgentPanel
Custom layout (modal, popover, iframe)AgentChat inside your own container