# ChatPanel

> The shell a conversation lives in: a sticky header, a transcript that pins itself to the bottom while an answer arrives and offers the way back once you scroll up, and a sticky composer row.

- Package: `fancy-ui-vue` (Vue 3.5+ + Tailwind CSS v4)
- Category: AI Chat
- Tags: ai, chat, panel, shell, compound
- Types: `ChatPanelProps`, `ChatEmptyStateProps`
- Docs: https://fancy-ui.rama.app/docs/components/chat-panel
- Source: https://github.com/RamaHerbin/fancy-ui/tree/main/vue/src/components/chat-panel

## Import

```vue
<script setup lang="ts">
import { ChatPanel } from 'fancy-ui-vue';
</script>
```

Setup (once per project): `npm install fancy-ui-vue`, then put these lines in your main CSS file (the stylesheet imports go right after `@import "tailwindcss";`):

```css
@import "tailwindcss";
@import "fancy-ui-vue/tailwind.css";
@import "fancy-ui-vue/styles.css";
```

Full guide: https://fancy-ui.rama.app/llms.txt

The names below are the ones to write in a Vue template; when one differs from the Svelte name, the Svelte name follows in parentheses. Snippets become named slots (`#default` is the default snippet), a prop the Vue port declares as a model is a `v-model:<name>` (except `ref`, exposed via `defineExpose({ ref })`: put a template ref on the component and read `.ref`) and callbacks are listeners (`onclick` is `@click`). Every component sets `inheritAttrs: false`: `class` is a declared prop, merged where the Svelte component applies it (not always the root element), and only when the props table below lists it; other attributes do not fall through unless the package README lists the component as forwarding native attributes. Divergences: https://github.com/RamaHerbin/fancy-ui/tree/main/vue#divergences-from-the-svelte-api

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `streaming` | `boolean` | `false` | Whether a reply is still arriving; pins the transcript to its bottom until the reader scrolls up |
| `empty` | `boolean` | `false` | Renders the emptyState snippet in place of the message stream |
| `returnLabel` | `string` | `"Jump to latest"` | Label on the pill offered once the reader scrolls away from the bottom |
| `sound` | `boolean` | `false` | Plays press on the jump-to-latest pill, once the user has enabled sound |

## Slots

| Slot | Description |
| --- | --- |
| `#header` (Svelte `header`) | Sticky top region: a title, a model name, a close button |
| `#default` (Svelte `children`) | The message stream, filling the scroll region |
| `#composer` (Svelte `composer`) | Sticky bottom region — where Composer belongs |
| `#emptyState` (Svelte `emptyState`) | Rendered instead of children while empty — where ChatEmptyState belongs |

## Example

```vue
<script setup lang="ts">
import { ref } from "vue";
import { ChatMessage, ChatPanel, Composer } from "fancy-ui-vue";

interface Turn {
	id: string;
	role: "user" | "assistant";
	content: string;
}

const turns = ref<Turn[]>([
	{ id: "t1", role: "user", content: "Why does my transcript jump around?" },
	{
		id: "t2",
		role: "assistant",
		content: "Something is scrolling it for you on every chunk, even when you were reading above.",
	},
]);
const draft = ref("");

function send({ text }: { text: string }) {
	turns.value.push({ id: `t${turns.value.length + 1}`, role: "user", content: text });
}
</script>

<template>
	<div class="h-[26rem] w-full max-w-xl">
		<ChatPanel>
			<template #header>
				<div class="flex items-center justify-between px-4 py-3">
					<p class="text-sm font-semibold">Scrolling behaviour</p>
				</div>
			</template>

			<div class="flex flex-col gap-5 px-4 py-4">
				<ChatMessage
					v-for="turn in turns"
					:key="turn.id"
					:role="turn.role"
					:content="turn.content"
				/>
			</div>

			<template #composer>
				<div class="p-3">
					<Composer v-model:value="draft" placeholder="Ask a follow-up" :on-submit="send" />
				</div>
			</template>
		</ChatPanel>
	</div>
</template>
```
