Skip to content
Agent UI
PrimitivesCode

Code

Inline code with a muted background that matches prose and tables.

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

tsx

Run pnpm add @agent-ui/react to install the library.

Installation

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

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

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 { Code } from "@agent-ui/react";
 
<p>Run <Code>pnpm add @agent-ui/react</Code> to install.</p>

API reference

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

API reference for this component
NameTypeDefaultDescription
childrenReactNode—Code text or inline markup.
classNamestring—Merged with the inline code recipe.
Use it with the rest of the library

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

3 lines · copy-ready