Skip to content

shadcn.io is an independent project built on shadcn/ui

Components

Free

Agent for Solid

An agent's setup on one card for Solid on Ark UI: its name and model, the system prompt, and tools that open into their JSON input schemas.

On this page11 sections
UI library: Ark UI

Agent is a card that describes an agent before it runs: its name and model, the system prompt it follows, the tools it may call, each opening into its input schema, and the shape of what it returns. Put it on an agent's settings page, in a picker that compares agents, or in the docs for an agent you ship.

To show what an agent did during a run, use Subagent for work it handed off or Tool for a single call.

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

The install adds Accordion for the tool rows, Badge for the model, and Code Block with its highlighter for the schemas.

Anatomy

Agent anatomy: root, header, instructions, tools, tool, output

Usage

import {
  Agent, AgentContent, AgentHeader, AgentInstructions, AgentOutput,
  AgentTool, AgentTools,
} from "@/components/ui/agent";
<Agent>
  <AgentHeader model="gpt-4o" name="Research Assistant" />
  <AgentContent>
    <AgentInstructions>Search the web and cite every source.</AgentInstructions>
    <AgentTools>
      <AgentTool
        tool={{
          description: "Search the web",
          jsonSchema: { properties: { query: { type: "string" } }, type: "object" },
        }}
        value="search"
      />
    </AgentTools>
    <AgentOutput schema="interface Result { answer: string }" />
  </AgentContent>
</Agent>

AgentHeader needs a name, and every other part is optional: a card shows only the parts you give it.

Accessibility

The tool rows sit in a group named by the label above them, Tools unless you set label. Each row is a <button> named by the tool's description, and aria-expanded tells a screen reader whether its schema is open. The button has no heading around it, and nothing else in the card is a heading either, so put the agent's name in a heading on the page when people need to jump to it. A schema scrolls inside its block, which takes focus so the arrow keys can scroll it. Its copy button appears on focus as well as on hover and announces "Copied". The bot icon is hidden from screen readers.

Space
When focus is on a tool's row, opens or closes its schema.
Enter
When focus is on a tool's row, opens or closes its schema.
Tab
Moves focus to the next focusable element: the next row, or in an open tool its copy button and then its schema.
Shift+Tab
Moves focus to the previous focusable element.
Arrow Down
When focus is on a row, moves it to the next row, and from the last one back to the first.
Arrow Up
When focus is on a row, moves it to the previous row, and from the first one to the last.
Home
When focus is on a row, moves it to the first row.
End
When focus is on a row, moves it to the last row.

Demos

Controlled

A support agent's three tools, with the refund tool open and an Expand all button in the header that turns into Collapse all once every row is open. The open rows live in the demo's own state, passed to AgentTools as value. Control the list this way when a link or a failed call should open one particular tool.

Preview width

Team

Three cards in a column for a researcher, a writer and a reviewer, each with its model and a count of its tools in an outline Badge at the end of the header. The cards hold only their instructions. Use this layout to compare agents that split one job, where the full tool schemas would bury the differences between them.

Preview width

AI SDK tools

A trip planner's two tools, a weather lookup and a flight search, written the way the AI SDK's tool() returns them: a description and an inputSchema wrapped as jsonSchema() wraps it. AgentTool unwraps the schema itself. The output schema is JSON, so AgentOutput gets language set to json. Start here when the card documents tools you already hand to a model.

Preview width

AI SDK

A tool from the AI SDK's tool() is a description and an input schema, which is what AgentTool takes.

A tool definition is data, so the card needs nothing from the AI SDK in Solid: give AgentTool an object with the tool's description and its JSON Schema, either as jsonSchema or wrapped in inputSchema the way the AI SDK tools demo writes it.

AgentTool reads the jsonSchema field of the wrapper that jsonSchema() and zodSchema() return, and converts nothing itself. A tool whose inputSchema is a bare Zod schema needs one of those first: wrap it in zodSchema() from ai, or pass the result of Zod 4's z.toJSONSchema() as jsonSchema. Show the model id you pass to the provider in AgentHeader's model, and the system prompt in AgentInstructions.

Migrating from AI SDK Elements

AI SDK Elements is for React, so there is nothing to migrate in Solid. Agent has the same parts and props here, and the demos above are the place to start.

FAQ

How do I list an agent's tools with their input schemas?

Put one AgentTool per tool inside AgentTools, each with the tool object as tool and a unique value. The row's label is the tool's description, or "No description" when it has none, and the row opens into the input schema printed as JSON in a Code Block.

AgentTool reads jsonSchema first and falls back to inputSchema, so an object with either field works. Several rows can be open at once unless you set multiple to false on AgentTools.

Can I pass AI SDK tools to the Agent component?

Yes. The AI SDK's tool() returns the object you give it, a description and an inputSchema, and that is what AgentTool reads. When the schema comes from jsonSchema() or zodSchema(), it is a wrapper whose jsonSchema field holds the JSON Schema, and AgentTool unwraps it.

A bare Zod schema as inputSchema is the exception, because AgentTool doesn't convert it. Wrap it in zodSchema() from ai, or pass the result of Zod 4's z.toJSONSchema() as jsonSchema. The AI SDK section maps a whole tools record to rows.

What is the difference between Agent and Subagent?

Agent describes an agent before it runs: the model, the system prompt, the tools it may call and the shape of its answer. It belongs on a settings page, in a picker or in your docs.

Subagent shows a run that already happened, as one line in the conversation that opens into the calls the subagent made and what it found. A chat that hands work to other agents shows Subagent lines in the thread, and the Agent card wherever people set those agents up.

How do I show an agent's output schema?

Pass the schema as a string to schema on AgentOutput: a TypeScript interface, a JSON Schema, or the source of a Zod schema. A JSON Schema object goes through JSON.stringify first. It's highlighted as TypeScript unless you set language, such as json, and a language the highlighter doesn't know shows as plain text.

The block stops growing at 18rem and scrolls inside, and its copy button copies the whole schema. Leave AgentOutput out when the agent answers in free text.

How do I open an Agent tool from code in Solid?

Hold the open tools' values in state, pass them to AgentTools as value, and update them in onValueChange, which receives an object whose value is the new array. The Controlled demo drives an Expand all button this way.

To open a tool from the first render without holding state, list its value in defaultValue instead. Open the tool a deep link names, or the one whose last call failed, so the reader lands on the schema they came for.

How do I style the parts of an Agent card?

Every part carries a data-slot you can target from CSS: agent, agent-header, agent-name, agent-model, agent-content, agent-instructions, agent-tools, agent-tool and agent-output. For lasting changes, edit components/ui/agent, which is your code once installed.

A class passed to a part merges with its own. On AgentTools it lands on the wrapper that holds the label, not on the bordered list, so restyle the list in the agent file. The rows and the schema blocks come from your Accordion and Code Block, so a change to those shows here too.

How do I show a long system prompt in AgentInstructions?

Pass the prompt as one string. AgentInstructions keeps its line breaks and wraps long lines, and the box grows with the text, with no height limit or scroll, so a prompt of several screens makes a tall card.

The text renders as written, so Markdown shows its asterisks and pound signs. For a long prompt, give the box in components/ui/agent a maximum height and let it scroll, or show the prompt elsewhere and keep a one-line summary in the card.

How do I add a button or a badge to the Agent header?

Put it inside AgentHeader as its children. They render after the name and the model badge, pushed to the far end of the row, which is where the Controlled demo puts its Expand all button and the Team demo its count of tools.

When the row runs short, the agent's name and the model badge both shrink and truncate with an ellipsis. A Badge or a Button you add keeps its full width, since both carry shrink-0, so keep what you put there short in a card that can get narrow.

API Reference

Agent

<div> data-slot="agent"

PropType
class?string

Merged with the part's classes.

AgentHeader

<div> data-slot="agent-header"

PropType
namestring

The agent's name.

model?string

The model it runs on, shown as a badge after its name.

class?string

Merged with the part's classes.

AgentContent

<div> data-slot="agent-content"

PropType
class?string

Merged with the part's classes.

AgentInstructions

<div> data-slot="agent-instructions"

PropType
childrenstring

The system prompt.

label?string

The heading above it.

Default
"Instructions"
class?string

Merged with the part's classes.

AgentTools

<div> data-slot="agent-tools"

PropType
value?string[]

The controlled value of the expanded accordion items.

defaultValue?string[]

The initial value of the expanded accordion items. Use when you don't need to control the value of the accordion.

onValueChange?(details: ValueChangeDetails) → void

The callback fired when the state of expanded/collapsed accordion items changes.

Type
(details: ValueChangeDetails) → void
Parameters

details – { value: string[] }

Returns
void
collapsible?boolean

Whether an accordion item can be closed after it has been expanded.

Default
false
dir?"ltr" | "rtl"

The document's text/writing direction.

Type
"ltr" | "rtl"
Default
"ltr"
disabled?boolean

Whether the accordion items are disabled.

hideMode?"display-none" | "activity"

How to hide content when mounted but not present. - display-none: HTML hidden attribute. Effects stay alive. - activity: React 19 <Activity mode="hidden">. Effects pause. Requires React 19+.

Type
"display-none" | "activity"
Default
"display-none"
id?string

The unique identifier of the machine.

ids?object

The ids of the elements in the accordion. Useful for composition.

Type
{ root?: string; item?: (value: string) → string; itemContent?: (value: string) → string; itemTrigger?: (value: string) → string }
label?string

The heading above the list.

Default
"Tools"
lazyMount?boolean

Whether to enable lazy mounting.

Default
false
multiple?boolean

Whether multiple accordion items can be expanded at the same time. Ark default: false.

Default
true
onFocusChange?(details: FocusChangeDetails) → void

The callback fired when the focused accordion item changes.

Type
(details: FocusChangeDetails) → void
Parameters

details – { value: string | null }

Returns
void
orientation?"horizontal" | "vertical"

The orientation of the accordion items.

Type
"horizontal" | "vertical"
Default
"vertical"
unmountOnExit?boolean

Whether to unmount on exit.

Default
false
asChild?(props: ParentProps) => JSX.Element

Render your own element: a function that gets the part's props to spread on it.

Type
(props: ParentProps) => JSX.Element
class?string

Merged with the part's classes.

AgentTool

data-slot="agent-tool"

PropType
toolobject

The tool: its description is the row, its input schema the panel.

Type
{ description?: string; inputSchema?: unknown; jsonSchema?: unknown }
valuestring

The value of the accordion item.

disabled?boolean

Whether the accordion item is disabled.

asChild?(props: ParentProps) => JSX.Element

Render your own element: a function that gets the part's props to spread on it.

Type
(props: ParentProps) => JSX.Element
class?string

Merged with the part's classes.

AgentOutput

<div> data-slot="agent-output"

PropType
schemastring

What the agent returns: a type or a JSON Schema, as text.

label?string

The heading above it.

Default
"Output Schema"
language?string

The language the schema is highlighted in.

Default
"typescript"
class?string

Merged with the part's classes.