Skip to content
Agent UI
Compose primitivesComposeProvider

Compose Provider

Context provider that owns text, model, toggles, send, and disabled state for a stage.

ComposeProvider ships with a full API table, a copyable example, and accessibility notes.

tsx

Installation

Install the package once, then import ComposeProvider from its direct entry point or from the root.

bash
pnpm add @agent-ui/react
tsx
import { ComposeProvider } from "@agent-ui/react";

Tailwind CSS v4 users: add @source "../node_modules/@agent-ui/react/src" to the global stylesheet so the library utilities are generated.

Usage

The example below is the same code that renders the preview. Copy it, swap in your own handlers, and ship.

tsx
import { ComposeProvider, ComposeTextarea } from "@agent-ui/react";
 
<ComposeProvider models={models} onSend={send}>
<ComposeTextarea aria-label="Message" placeholder="Ask anything" />
</ComposeProvider>

API reference

Every prop ComposeProvider accepts, its type, default, and behaviour.

API reference for this component
NameTypeDefaultDescription
modelsComposeModelOption[][]Model menu options with optional hints.
defaultModelIdstring—Initially selected model.
initialTogglesRecord<string, boolean>{}Initial tool toggle state.
disabledbooleanfalseBlocks typing and sending.
onSend(text: string) => void—Called with trimmed text.
childrenReactNode—Stage content.
Use it with the rest of the library

ComposeProvider composes with MessageList, ChatShell, useChat, and the provider compose blocks. Browse the full reference or see all components in the gallery.

5 lines · copy-ready