shadcn.io is an independent project built on shadcn/ui
On this page11 sections
Schema Display puts one HTTP endpoint on a card: the method and path, a line on what it does, then its parameters and the request and response bodies, whose object and array fields open into their own fields. Reach for it to document the API behind an agent's tool or a webhook the agent receives.
To show a call that already ran, with its real input and output, use a Tool instead.
Installation
The install adds Badge for the method and the field types, and Collapsible for the sections that open.
Anatomy

Usage
import { SchemaDisplay } from "@/components/ui/schema-display";<SchemaDisplay
description="Send a message to a specific user"
method="POST"
parameters={[
{ location: "path", name: "userId", required: true, type: "string" },
]}
path="/api/users/{userId}/messages"
requestBody={[{ name: "content", required: true, type: "string" }]}
responseBody={[{ name: "id", type: "string" }]}
/>With no children, SchemaDisplay draws the header, the description when there is one, and a section for each list that has entries. Give it children to lay the parts out yourself, as the Composed demo does: each part reads the method, the path and the lists from the root.
Accessibility
Parameters, Request Body, Response and every field with fields of its own open from a <button> that reports aria-expanded, so a screen reader hears whether each one is open. A field's description sits outside its button, which keeps the button's name to the field, its type and the word required. The method and required are written out, so neither depends on color. While a section is closed, its rows are hidden from screen readers and out of the tab order.
The example block takes focus so a keyboard can scroll it. It is a region, so an aria-label on it names that stop for a screen reader, as the Example response label in the Composed demo does.
- Tab
- Moves focus to the next section or field that opens, then to the example block where there is one.
- Shift+Tab
- Moves focus back through the same stops.
- Enter
- Opens or closes the focused section or field.
- Space
- Opens or closes the focused section or field.
Demos
Nested
An order endpoint whose request body holds a customer object with an address inside it, and an items array of products. A field with properties opens into its fields, and one with items opens into a single items[] entry. Each level steps in by 1rem, and every field here starts open, since only a field that opens three levels down starts closed.
Methods
Five endpoints of one users resource, one per method, each card only a header with its description at the end. GET is green, POST blue, PUT and PATCH amber and DELETE red, from Badge's status variants. Use header-only cards for an index that links to full ones, with a fixed method width, w-16 here, so the paths line up.
Composed
A weather endpoint laid out by hand: Parameters starts closed with its count of three in view, there is no request body, and a JSON example response sits under the fields in SchemaDisplayExample. Compose the parts when the default order doesn't fit, when a section should start closed, or to add something of your own between them.
From JSON Schema
A tool's input is described in JSON Schema, and so is a request body in an OpenAPI document. Schema Display takes a flat shape of its own, so turn the schema's properties into SchemaProperty objects and pass them as requestBody.
type JsonSchema = {
description?: string;
items?: JsonSchema;
properties?: Record<string, JsonSchema>;
required?: string[];
type?: string;
};
const toProperties = (schema: JsonSchema): SchemaProperty[] =>
Object.entries(schema.properties ?? {}).map(([name, field]) => ({
description: field.description,
items: field.items
? {
name: "item",
properties: field.items.properties
? toProperties(field.items)
: undefined,
type: field.items.type ?? "unknown",
}
: undefined,
name,
properties: field.properties ? toProperties(field) : undefined,
required: schema.required?.includes(name),
type: field.type ?? "unknown",
}));The function follows properties into objects and items into arrays, and marks a field required when its name is in the schema's required list. SchemaProperty and SchemaParameter are exported from @/components/ui/schema-display, so the result type-checks against what the component takes.
Migrating from AI SDK Elements
AI SDK Elements is for React. In Solid, Schema Display has the same parts and props, so its demos are the place to start.
FAQ
Which HTTP methods does Schema Display support?
GET, POST, PUT, PATCH and DELETE, the five in its HttpMethod type. Each gets a Badge variant from METHOD_VARIANTS: success for GET, info for POST, warning for PUT and PATCH, and destructive for DELETE, so the colors come from your theme and hold in dark mode.
For HEAD, OPTIONS or any other method, add it to HttpMethod and give it a variant in METHOD_VARIANTS, both in the schema display code under components/ui. The badge also carries data-method, so a style can single out one method.
How do I show path, query and header parameters in Solid?
Pass them as parameters on SchemaDisplay. Each needs a name and a type, and can add a location of path, query or header, required and a description. They list under Parameters, with their count beside the heading and the type and location as badges on each row.
A path parameter needs nothing more to show in the path itself. Every name in curly braces in path, such as the userId in the demo at the top of the page, is highlighted whether or not it is in the list.
How does Schema Display show nested objects and arrays?
A field with properties opens into its fields, and a field with items opens into one entry named after it with brackets on the end, such as items[]. Each level steps in by 1rem, and the fields keep a rule between them at every depth.
The first two levels start open and a field that opens deeper than that starts closed, so a large body still fits on screen. To change where that line falls, edit the depth < 2 check in SchemaDisplayProperty. The Nested demo shows an object inside an object and an array of objects.
How do I show a tool's JSON Schema with Schema Display?
Convert the schema's properties into SchemaProperty objects and pass them as requestBody. The toProperties function in the From JSON Schema section does that, following objects and array items and marking the names the schema lists as required.
Schema Display doesn't read JSON Schema on its own, so the conversion is yours. If the tool's input is a Zod schema, Zod 4's z.toJSONSchema turns it into JSON Schema first.
How do I lay out the parts of a Schema Display myself?
Give SchemaDisplay children and it renders only those, while every part still reads the method, path, description and lists from the root. Leave a section out, change the order, or put a SchemaDisplayExample under the fields, as the Composed demo does.
A section laid out this way can start closed: set defaultOpen to false on SchemaDisplayParameters, SchemaDisplayRequest or SchemaDisplayResponse. All three start open otherwise.
How do I change the colors or spacing of a Schema Display?
Edit the schema display code under components/ui, which is yours once installed: the padding, hover and focus ring of every section and field that opens sit in its TRIGGER classes. Every part has its own data-slot, and each field sets data-depth, so a style can reach one part or one level of nesting. For a one-off change, add a class to the part.
The badges are your Badge, so their size and shape come from that file, and the method colors follow your theme's success, info, warning and destructive tokens. The sections open and close with your Collapsible's animation.
How are path parameters highlighted in Schema Display?
Each name in curly braces in the path is wrapped in its own span, in the primary color, with data-slot set to schema-display-path-param so you can restyle it. Pass children to SchemaDisplayPath to render your own markup instead.
The path wraps at any character when it is too long for the card, so a long URL never pushes the card wider than its container.
Does Schema Display work on a right-to-left page?
Yes, inside a Direction provider set to right to left. The header and description follow the page, but Ark UI writes a dir on each section's trigger and content from its own locale, left to right until a provider changes it. Without one, the sections and their fields keep a left-to-right layout, chevrons included, since each chevron mirrors only when its own row runs right to left.
The path, the field names, the types and the example always read left to right, since each has dir set to ltr. A path or a JSON body stays readable that way inside Arabic or Hebrew prose.
API Reference
SchemaDisplay
methodHttpMethod
The HTTP method: its badge's color.
pathstring
The path; each {param} in it is highlighted.
description?string
What the endpoint does, under its header.
parameters?SchemaParameter[]
Its path, query and header parameters.
requestBody?SchemaProperty[]
The request body's fields.
responseBody?SchemaProperty[]
The response body's fields.
class?string
Merged with the part's classes.
SchemaDisplayHeader
<div> data-slot="schema-display-header"
class?string
Merged with the part's classes.
SchemaDisplayMethod
data-slot="schema-display-method"
pill?boolean
Fully rounded corners.
- Default
false
size?"lg" | "md" | "sm"
The size.
- Type
"lg" | "md" | "sm"- Default
"md"
variant?"default" | "destructive" | "ghost" | "info" | "link" | "outline" | "secondary" | "success" | "warning"
The visual style.
- Type
"default" | "destructive" | "ghost" | "info" | "link" | "outline" | "secondary" | "success" | "warning"- Default
"default"
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.
data-method?string
Mirrors method.
SchemaDisplayPath
<span> data-slot="schema-display-path"
class?string
Merged with the part's classes.
SchemaDisplayDescription
<p> data-slot="schema-display-description"
class?string
Merged with the part's classes.
SchemaDisplayContent
<div> data-slot="schema-display-content"
class?string
Merged with the part's classes.
SchemaDisplayParameters
data-slot="schema-display-parameters"
open?boolean
The controlled open state of the collapsible.
defaultOpen?boolean
The initial open state of the collapsible when rendered. Use when you don't need to control the open state of the collapsible.
- Default
true
onOpenChange?(details: OpenChangeDetails) → void
The callback invoked when the open state changes.
- Type
(details: OpenChangeDetails) → void- Parameters
details– { open: boolean }- Returns
void
collapsedHeight?number | string
The height of the content when collapsed.
- Type
number | string
collapsedWidth?number | string
The width of the content when collapsed.
- Type
number | string
dir?"ltr" | "rtl"
The document's text/writing direction.
- Type
"ltr" | "rtl"- Default
"ltr"
disabled?boolean
Whether the collapsible is 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 collapsible. Useful for composition.
- Type
{ root?: string; content?: string; trigger?: string }
lazyMount?boolean
Whether to enable lazy mounting.
- Default
false
onExitComplete?VoidFunction
The callback invoked when the exit animation completes.
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.
SchemaDisplayParameter
<div> data-slot="schema-display-parameter"
namestring
The parameter's name, as the request spells it.
typestring
Its type, shown as a badge (string, integer, boolean…).
description?string
What the parameter does, under its name.
location?"path" | "query" | "header"
Where the request carries it: in the path, the query string or a header.
- Type
"path" | "query" | "header"
required?boolean
Marks it required; the rest are optional.
class?string
Merged with the part's classes.
SchemaDisplayRequest
data-slot="schema-display-request"
open?boolean
The controlled open state of the collapsible.
defaultOpen?boolean
The initial open state of the collapsible when rendered. Use when you don't need to control the open state of the collapsible.
- Default
true
onOpenChange?(details: OpenChangeDetails) → void
The callback invoked when the open state changes.
- Type
(details: OpenChangeDetails) → void- Parameters
details– { open: boolean }- Returns
void
collapsedHeight?number | string
The height of the content when collapsed.
- Type
number | string
collapsedWidth?number | string
The width of the content when collapsed.
- Type
number | string
dir?"ltr" | "rtl"
The document's text/writing direction.
- Type
"ltr" | "rtl"- Default
"ltr"
disabled?boolean
Whether the collapsible is 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 collapsible. Useful for composition.
- Type
{ root?: string; content?: string; trigger?: string }
lazyMount?boolean
Whether to enable lazy mounting.
- Default
false
onExitComplete?VoidFunction
The callback invoked when the exit animation completes.
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.
SchemaDisplayResponse
data-slot="schema-display-response"
open?boolean
The controlled open state of the collapsible.
defaultOpen?boolean
The initial open state of the collapsible when rendered. Use when you don't need to control the open state of the collapsible.
- Default
true
onOpenChange?(details: OpenChangeDetails) → void
The callback invoked when the open state changes.
- Type
(details: OpenChangeDetails) → void- Parameters
details– { open: boolean }- Returns
void
collapsedHeight?number | string
The height of the content when collapsed.
- Type
number | string
collapsedWidth?number | string
The width of the content when collapsed.
- Type
number | string
dir?"ltr" | "rtl"
The document's text/writing direction.
- Type
"ltr" | "rtl"- Default
"ltr"
disabled?boolean
Whether the collapsible is 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 collapsible. Useful for composition.
- Type
{ root?: string; content?: string; trigger?: string }
lazyMount?boolean
Whether to enable lazy mounting.
- Default
false
onExitComplete?VoidFunction
The callback invoked when the exit animation completes.
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.
SchemaDisplayBody
<div> data-slot="schema-display-body"
class?string
Merged with the part's classes.
SchemaDisplayProperty
<div> data-slot="schema-display-property"
namestring
The field's key in the body.
typestring
Its type, shown as a badge (string, object, array…).
depth?number
How deep in the body it is: each level steps in 1rem.
- Default
0
description?string
What the field holds, under its name.
items?object
For an array: the shape of each item, which opens under the field.
- Type
{ description?: string; items?: SchemaProperty; name: string; properties?: SchemaProperty[]; required?: boolean; type: string }
properties?SchemaProperty[]
For an object: its fields, which open under it.
required?boolean
Marks it required; the rest are optional.
class?string
Merged with the part's classes.
data-depth?string
Mirrors depth.
SchemaDisplayExample
<pre> data-slot="schema-display-example"
class?string
Merged with the part's classes.











