# Schema Display Example

> Example implementation of schema display.

A shadcn/ui block from the [@ai-elements](https://ai-sdk.dev/elements) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/ai-elements/example-schema-display).

- Page, with a live preview: https://shadcn.exchange/r/ai-elements/example-schema-display
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/ai-elements/example-schema-display-light-81aeacbe84ab6503.png
- Registry item: https://ai-sdk.dev/elements/api/registry/example-schema-display.json
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://ai-sdk.dev/elements/api/registry/example-schema-display.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- Registry items: `https://elements.ai-sdk.dev/schema-display.json`

## Files

### `registry/default/examples/schema-display.tsx`

```tsx
"use client";

import {
  SchemaDisplay,
  SchemaDisplayContent,
  SchemaDisplayDescription,
  SchemaDisplayHeader,
  SchemaDisplayMethod,
  SchemaDisplayParameters,
  SchemaDisplayPath,
  SchemaDisplayRequest,
  SchemaDisplayResponse,
} from "@/components/ai-elements/schema-display";

const Example = () => (
  <SchemaDisplay
    description="Create a new post for a specific user. Requires authentication."
    method="POST"
    parameters={[
      {
        description: "The unique identifier of the user",
        location: "path",
        name: "userId",
        required: true,
        type: "string",
      },
      {
        description: "Save as draft instead of publishing",
        location: "query",
        name: "draft",
        required: false,
        type: "boolean",
      },
    ]}
    path="/api/users/{userId}/posts"
    requestBody={[
      {
        description: "The post title",
        name: "title",
        required: true,
        type: "string",
      },
      {
        description: "The post content in markdown format",
        name: "content",
        required: true,
        type: "string",
      },
      {
        description: "Tags for categorization",
        items: { name: "tag", type: "string" },
        name: "tags",
        type: "array",
      },
      {
        description: "Additional metadata",
        name: "metadata",
        properties: [
          {
            description: "SEO optimized title",
            name: "seoTitle",
            type: "string",
          },
          {
            description: "Meta description",
            name: "seoDescription",
            type: "string",
          },
        ],
        type: "object",
      },
    ]}
    responseBody={[
      { description: "Post ID", name: "id", required: true, type: "string" },
      { name: "title", required: true, type: "string" },
      { name: "content", required: true, type: "string" },
      {
        description: "ISO 8601 timestamp",
        name: "createdAt",
        required: true,
        type: "string",
      },
      {
        name: "author",
        properties: [
          { name: "id", required: true, type: "string" },
          { name: "name", required: true, type: "string" },
          { name: "avatar", type: "string" },
        ],
        required: true,
        type: "object",
      },
    ]}
  >
    <SchemaDisplayHeader>
      <div className="flex items-center gap-3">
        <SchemaDisplayMethod />
        <SchemaDisplayPath />
      </div>
    </SchemaDisplayHeader>
    <SchemaDisplayDescription />
    <SchemaDisplayContent>
      <SchemaDisplayParameters />
      <SchemaDisplayRequest />
      <SchemaDisplayResponse />
    </SchemaDisplayContent>
  </SchemaDisplay>
);

export default Example;
```
