Skip to content
Agent UI
Compose primitivescreateCompose

createCompose & withComposeLayout

Factories that pre-bind a provider's static config to a shell and context, plus an HOC variant.

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

tsx

Installation

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

bash
pnpm add @agent-ui/react
tsx
import { createCompose } 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 { createCompose, ComposeCard, ComposeTextarea } from "@agent-ui/react";
 
const MyCompose = createCompose({
id: "acme",
models: [{ id: "fast", name: "Fast" }],
maxWidth: "max-w-none",
});
 
<MyCompose onSend={send}>
<ComposeCard>
<ComposeTextarea aria-label="Message" />
</ComposeCard>
</MyCompose>

API reference

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

API reference for this component
NameTypeDefaultDescription
idstring—Stage id used for data-agent-id.
herostring—Optional hero heading.
placeholderstring—Default prompt placeholder.
modelsComposeModelOption[][]Model menu options.
defaultModelIdstring—Initially selected model.
initialTogglesRecord<string, boolean>{}Initial tool toggles.
maxWidthstring"max-w-3xl"Stage max-width class.
footerReactNode—Stage footer.
Use it with the rest of the library

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

13 lines · copy-ready