# Chat Dock

Floating chat widget launcher that opens a docked support chat panel built on a dialog, pinned to the viewport or a container, with optional scrim and header, body and footer parts.

Component · Chat · https://01orbital.dev/docs/components/chat-dock

## Installation

```bash
npx shadcn@latest add @01orbital/chat-dock
```

## Usage

```tsx
"use client"

import * as React from "react"

import { ChatComposer } from "@/components/chat/chat-composer"
import { ChatConversation } from "@/components/chat/chat-conversation"
import {
  ChatDock,
  ChatDockBody,
  ChatDockFooter,
  ChatDockHeader,
  ChatDockTitle,
} from "@/components/chat/chat-dock"
import { ChatMessage } from "@/components/chat/chat-message"
import { ChatResponse } from "@/components/chat/chat-response"
import {
  MessageScrollerContent,
  MessageScrollerItem,
} from "@/components/ui/message-scroller"

// Every word on the page. Change copy here, not in the markup.
const COPY = {
  title: "Ask Orbcore",
  question: "Can I change the copy and the layout?",
  answer:
    "Every block keeps its words in a constant at the top of the file and its layout in named parts.",
  placeholder: "Ask anything…",
} as const

// The dock, open, anchored to this frame instead of the viewport.
export default function ChatDockDemo() {
  const frameRef = React.useRef<HTMLDivElement>(null)
  const [open, setOpen] = React.useState(true)
  const [sent, setSent] = React.useState<string[]>([])

  return (
    <div ref={frameRef} className="relative h-144 w-full overflow-hidden">
      <ChatDock
        open={open}
        onOpenChange={setOpen}
        anchor="container"
        container={frameRef}
      >
        <ChatDockHeader>
          <ChatDockTitle>{COPY.title}</ChatDockTitle>
        </ChatDockHeader>
        <ChatDockBody className="flex flex-col">
          <ChatConversation className="px-4 py-4">
            <MessageScrollerContent className="gap-6">
              <MessageScrollerItem messageId="usr-opening" scrollAnchor>
                <ChatMessage variant="mine">{COPY.question}</ChatMessage>
              </MessageScrollerItem>
              <MessageScrollerItem messageId="asst-opening">
                <ChatResponse
                  className="text-sm/7 text-foreground"
                  text={COPY.answer}
                />
              </MessageScrollerItem>
              {sent.map((line, i) => (
                <MessageScrollerItem
                  key={i}
                  messageId={`sent-${i}`}
                  scrollAnchor
                >
                  <ChatMessage variant="mine">{line}</ChatMessage>
                </MessageScrollerItem>
              ))}
            </MessageScrollerContent>
          </ChatConversation>
        </ChatDockBody>
        <ChatDockFooter>
          <ChatComposer
            onSend={(value) => setSent((prev) => [...prev, value])}
            onStop={() => {}}
            streaming={false}
            placeholder={COPY.placeholder}
          />
        </ChatDockFooter>
      </ChatDock>
    </div>
  )
}
```

This example installs with everything it uses:

```bash
npx shadcn@latest add @01orbital/chat-dock-demo
```

## API reference

### ChatDock

A floating chat: a round launcher in the corner that opens a chat panel above it. Put `ChatDockHeader`, `ChatDockBody` and `ChatDockFooter` inside.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `open` | `boolean` |  | Whether the panel is open. |
| `onOpenChange` | `(open: boolean) => void` |  | Called when the launcher, the close button or Escape opens or closes it. |
| `anchor?` | `Anchor` | `"viewport"` | "viewport" pins the launcher and panel to the window's bottom-right corner; "container" pins them to the nearest positioned ancestor, so a dock can sit inside a frame or demo. |
| `scrim?` | `boolean` | `false` | Dims and blurs the page behind the open panel, and makes it modal. |
| `container?` | `React.RefObject<HTMLElement \| null>` |  | Where the panel renders, such as the frame "container" anchors to. |
| `launcherLabel?` | `string` | `"Ask a question"` | The launcher's accessible name. |
| `icon?` | `React.ReactNode` |  | Replaces the launcher's chat icon, such as with an orb. |
| `bare?` | `boolean` | `false` | The icon is the whole button (an orb, say): no round fill or ring. |
| `children` | `React.ReactNode` |  | The panel's content, usually a `ChatDockHeader`, `ChatDockBody` and `ChatDockFooter`. |

## Dependencies

Requires these pieces. The CLI adds each one that is missing and won't replace a file you already have unless you choose to:

- [Button](https://01orbital.dev/docs/components/button)

The shadcn parts here are their Base UI versions, and this piece uses Base UI's API. A Radix version you already have won't work with it.

npm: `@base-ui/react`, `@phosphor-icons/react`, `cn`
