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.
Installation
Install the package once, then import createCompose from its direct entry point or from the root.
pnpm add @agent-ui/reactimport { 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.
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.
| Name | Type | Default | Description |
|---|---|---|---|
| id | string | — | Stage id used for data-agent-id. |
| hero | string | — | Optional hero heading. |
| placeholder | string | — | Default prompt placeholder. |
| models | ComposeModelOption[] | [] | Model menu options. |
| defaultModelId | string | — | Initially selected model. |
| initialToggles | Record<string, boolean> | {} | Initial tool toggles. |
| maxWidth | string | "max-w-3xl" | Stage max-width class. |
| footer | ReactNode | — | Stage footer. |
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