# @llamaindex/chat-ui

> Chat UI components for LLM apps

Latest version **0.6.1** (published 2025-08-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install @llamaindex/chat-ui
pnpm add @llamaindex/chat-ui
yarn add @llamaindex/chat-ui
bun add @llamaindex/chat-ui
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.6.1 |
| Published | 2025-08-28 |
| First published | 2024-10-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 34 |
| Unpacked size | 1.8 MB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | emanuelclferreira, himself_65, marcusschiesser, octopoedi, zhaotai, cle-does-things, cheesyfishes, disiok, adrianlyjak, tuanacelik95 |

## Links

- npm: https://www.npmjs.com/package/@llamaindex/chat-ui
- npm.io page: https://npm.io/package/@llamaindex/chat-ui

## Dependencies (34)

- [clsx](https://npm.io/package/clsx.md) ^2.1.1
- [uuid](https://npm.io/package/uuid.md) ^11.1.0
- [vaul](https://npm.io/package/vaul.md) ^0.9.1
- [katex](https://npm.io/package/katex.md) ^0.16.21
- [remark](https://npm.io/package/remark.md) ^15.0.1
- [remark-gfm](https://npm.io/package/remark-gfm.md) ^3.0.1
- [remark-math](https://npm.io/package/remark-math.md) ^5.1.1
- [highlight.js](https://npm.io/package/highlight.js.md) ^11.10.0
- [lucide-react](https://npm.io/package/lucide-react.md) ^0.453.0
- [rehype-katex](https://npm.io/package/rehype-katex.md) ^7.0.0
- [remark-parse](https://npm.io/package/remark-parse.md) ^11.0.0
- [react-markdown](https://npm.io/package/react-markdown.md) ^8.0.7
- [tailwind-merge](https://npm.io/package/tailwind-merge.md) ^2.1.0
- [unist-util-visit](https://npm.io/package/unist-util-visit.md) ^5.0.0
- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) ^3.35.0
- [remark-code-import](https://npm.io/package/remark-code-import.md) ^1.2.0
- [@codemirror/lang-css](https://npm.io/package/@codemirror/lang-css.md) ^6.3.1
- [@radix-ui/react-slot](https://npm.io/package/@radix-ui/react-slot.md) ^1.0.2
- [@radix-ui/react-tabs](https://npm.io/package/@radix-ui/react-tabs.md) ^1.1.0
- [@codemirror/lang-html](https://npm.io/package/@codemirror/lang-html.md) ^6.4.9
- [@radix-ui/react-icons](https://npm.io/package/@radix-ui/react-icons.md) ^1.3.0
- [@uiw/react-codemirror](https://npm.io/package/@uiw/react-codemirror.md) ^4.23.12
- [@llamaindex/pdf-viewer](https://npm.io/package/@llamaindex/pdf-viewer.md) 1.3.0
- [@radix-ui/react-select](https://npm.io/package/@radix-ui/react-select.md) ^2.1.1
- [@codemirror/lang-python](https://npm.io/package/@codemirror/lang-python.md) ^6.2.0
- [@radix-ui/react-popover](https://npm.io/package/@radix-ui/react-popover.md) ^1.1.7
- [@llamaindex/llama-deploy](https://npm.io/package/@llamaindex/llama-deploy.md) 0.0.2
- [@radix-ui/react-progress](https://npm.io/package/@radix-ui/react-progress.md) ^1.1.0
- [class-variance-authority](https://npm.io/package/class-variance-authority.md) ^0.7.0
- [@radix-ui/react-accordion](https://npm.io/package/@radix-ui/react-accordion.md) ^1.2.3
- [@radix-ui/react-hover-card](https://npm.io/package/@radix-ui/react-hover-card.md) ^1.0.7
- [@codemirror/lang-javascript](https://npm.io/package/@codemirror/lang-javascript.md) ^6.2.3
- [@radix-ui/react-collapsible](https://npm.io/package/@radix-ui/react-collapsible.md) ^1.0.3
- [@uiw/codemirror-theme-github](https://npm.io/package/@uiw/codemirror-theme-github.md) ^4.23.12

## Recent versions

- 0.6.1 (latest) — 2025-08-28
- 0.6.0 — 2025-08-13
- 0.5.17 — 2025-07-21
- 0.5.16 — 2025-07-10
- 0.5.15 — 2025-07-09
- 0.5.14 — 2025-07-09
- 0.5.13 — 2025-07-02
- 0.5.12 — 2025-07-01
- 0.5.11 — 2025-06-27
- 0.5.10 — 2025-06-25
- 0.5.9 — 2025-06-19
- 0.5.8 — 2025-06-19
- 0.5.7 — 2025-06-18
- 0.5.6 — 2025-06-06
- 0.5.5 — 2025-06-05
- … 35 more at https://npm.io/package/@llamaindex/chat-ui/versions

## README

# @llamaindex/chat-ui

Chat UI components for LLM apps

## Overview

@llamaindex/chat-ui is a React component library that provides ready-to-use UI elements for building chat interfaces in LLM (Large Language Model) applications. This package is designed to streamline the development of chat-based user interfaces for AI-powered applications.

## Quick Start

You can quickly add a chatbot to your project by using Shadcn CLI command:

```sh
npx shadcn@latest add https://ui.llamaindex.ai/r/chat.json
```

## Manual Installation

To install the package, run the following command in your project directory:

```sh
npm install @llamaindex/chat-ui
```

## Features

- Pre-built chat components (e.g., message bubbles, input fields)
- Minimal styling, fully customizable with Tailwind CSS
- Custom widgets to extend components (e.g., for rendering generated or retrieved documents)
- TypeScript support for type safety
- Easy integration with LLM backends like Vercel Ai
- Code and Latex styling with highlight.js and katex

## Usage

1. Install the package

```sh
npm install @llamaindex/chat-ui
```

2. Configure Tailwind CSS to include the chat-ui components

For Tailwind CSS version 4.x, update `globals.css` to include the chat-ui components (update the relative path to node_modules if necessary):

```css
@source '../node_modules/@llamaindex/chat-ui/**/*.{ts,tsx}';
```

For Tailwind CSS version 3.x, you need to add the following to your `tailwind.config.ts` file:

```ts
module.exports = {
  content: [
    'app/**/*.{ts,tsx}',
    'node_modules/@llamaindex/chat-ui/**/*.{ts,tsx}',
  ],
  // ...
}
```

3. Import the components and use them

The easiest way to get started is to connect the whole `ChatSection` component with `useChat` hook from [vercel/ai](https://github.com/vercel/ai):

```tsx
import { ChatSection } from '@llamaindex/chat-ui'
import { useChat } from '@ai-sdk/react'

const ChatExample = () => {
  const handler = useChat()
  return <ChatSection handler={handler} />
}
```

This simple example looks like this:

![output](https://github.com/user-attachments/assets/fdf008a3-52b4-49ef-8db5-c9388d4fb8fa)

## Component Composition

Components are designed to be composable. You can use them as is:

```tsx
import { ChatSection } from '@llamaindex/chat-ui'
import { useChat } from '@ai-sdk/react'

const ChatExample = () => {
  const handler = useChat()
  return <ChatSection handler={handler} />
}
```

Or you can extend them with your own children components:

```tsx
import { ChatSection, ChatMessages, ChatInput } from '@llamaindex/chat-ui'
import LlamaCloudSelector from './components/LlamaCloudSelector' // your custom component
import { useChat } from '@ai-sdk/react'

const ChatExample = () => {
  const handler = useChat()
  return (
    <ChatSection handler={handler}>
      <ChatMessages />
      <ChatInput>
        <ChatInput.Form className="bg-lime-500">
          <ChatInput.Field type="textarea" />
          <ChatInput.Upload />
          <LlamaCloudSelector /> {/* custom component */}
          <ChatInput.Submit />
        </ChatInput.Form>
      </ChatInput>
    </ChatSection>
  )
}
```

Your custom component can use the `useChatUI` hook to send additional data to the chat API endpoint:

```tsx
import { useChatInput } from '@llamaindex/chat-ui'

const LlamaCloudSelector = () => {
  const { requestData, setRequestData } = useChatUI()
  return (
    <div>
      <select
        value={requestData?.model}
        onChange={e => setRequestData({ model: e.target.value })}
      >
        <option value="llama-3.1-70b-instruct">Pipeline 1</option>
        <option value="llama-3.1-8b-instruct">Pipeline 2</option>
      </select>
    </div>
  )
}
```

## Styling

### Components

`chat-ui` components are based on [shadcn](https://ui.shadcn.com/) components using Tailwind CSS.

You can override the default styles by changing CSS variables in the `globals.css` file of your Tailwind CSS configuration. For example, to change the background and foreground colors:

```css
:root {
  --background: 0 0% 100%;
  --foreground: 222.2 84% 4.9%;
}
```

For a list of all available CSS variables, please refer to the [Shadcn Theme Config](https://ui.shadcn.com/themes).

Additionally, you can also override each component's styles by setting custom classes in the `className` prop. For example, setting the background color of the `ChatInput.Form` component:

```tsx
import { ChatSection, ChatMessages, ChatInput } from '@llamaindex/chat-ui'
import { useChat } from '@ai-sdk/react'

const ChatExample = () => {
  const handler = useChat()
  return (
    <ChatSection handler={handler}>
      <ChatMessages />
      <ChatInput>
        <ChatInput.Preview />
        <ChatInput.Form className="bg-lime-500">
          <ChatInput.Field type="textarea" />
          <ChatInput.Upload />
          <ChatInput.Submit />
        </ChatInput.Form>
      </ChatInput>
    </ChatSection>
  )
}
```

### Code and Latex styling

Inside the markdown component, we use [highlight.js](https://highlightjs.org/) for code blocks, [katex](https://katex.org/) for latex, and [pdf-viewer](https://github.com/run-llama/pdf-viewer) for pdf files.
If your app is using code, latex or pdf files, you'll need to import their CSS files:

```tsx
import '@llamaindex/chat-ui/styles/markdown.css' // code, latex and custom markdown styling
import '@llamaindex/chat-ui/styles/pdf.css' // pdf styling
import '@llamaindex/chat-ui/styles/editor.css' // document editor styling
```

The `code.css` file uses the `atom-one-dark` theme from highlight.js by default. There are a lot of others to choose from: https://highlightjs.org/demo
You can use any of them by copying [their CSS](https://github.com/highlightjs/highlight.js/tree/main/src/styles/) to your project and importing it.

## Language renderer support (e.g. mermaid)

For any language that the LLM generates, you can specify a custom renderer to render the output.
We have an example for how to render mermaid code as SVG using [a custom renderer](./apps/web/app/demo/mermaid/).

## Example

See the [example app](https://github.com/run-llama/chat-ui/blob/main/apps/web/README.md) for a complete example. The generate a full-featured project to
get started with, use [create-llama](https://github.com/run-llama/create-llama).

## License

@llamaindex/chat-ui is released under the [MIT License](LICENSE).

## Support

If you encounter any issues or have questions, please file an issue on our [GitHub repository](https://github.com/run-llama/chat-ui/issues).

---
_Source: https://npm.io/package/@llamaindex/chat-ui · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
