---
title: "API Reference"
description: "A props table for a docs page: types, defaults, full types that open, inherited props, and a Keyboard card. You give it the data."
url: https://gelatinui.com/components/api-reference
markdown_url: https://gelatinui.com/components/api-reference.md
access: pro
install: "npx shadcn@latest add @gelatin-ui-pro/api-reference"
version: "2026-11-10"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# API Reference

> A props table for a docs page: types, defaults, full types that open, inherited props, and a Keyboard card. You give it the data.

Page: https://gelatinui.com/components/api-reference

## When to use it

Best for: A docs page that lists the props of a component part, from data you write or map from a docs tool.

- Map the output of react-docgen, TypeDoc, or your own script to `ApiReferencePartData`, one object per part.
- Compose the parts to fold long lists, add a row by hand, or leave a group out.
- Use `ApiReferenceKeyboard` for the keys of the same component.

## When not to use it

- For a table of app data that people sort and filter, use the [Table](https://gelatinui.com/components/table.md).
- For one code sample, use the [Code Block](https://gelatinui.com/components/code-block.md).

## Notes for agents

- The data is plain JSON except `description`, which takes a string (text in backticks is code) or any React node.
- `inherited.source` names the library (`Base UI`, `Radix UI`); the group row and the fold text use it.
- A prop in both `props` and `inherited.props` shows once, in the own rows.
- Give each table on one page its own `idPrefix`: the anchor id of a prop is `<idPrefix>-<prop>`.
- `ApiReferenceOwnProps` and `ApiReferenceInherited` take `collapseAfter`; the own props show all rows by default, the inherited props 3.
- A key press is a string (one key, never split: `Page Up`) or an array of keys pressed together (`['⌘', 'K']`).
- Keep a `labels` object and its functions at module level.

## Anatomy

```text
ApiReference
├─ ApiReferenceRow (0..n)
├─ ApiReferenceHeader (0..n)
├─ ApiReferenceTitle (0..n)
├─ ApiReferenceElement (0..n)
├─ ApiReferenceDescription (0..n)
├─ ApiReferenceTable (0..n)
├─ ApiReferenceInherited (0..n)
├─ ApiReferenceRest (0..n)
└─ ApiReferenceKeyboard (0..n)
```

## API reference

### ApiReferenceRow

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `prop` | `ApiReferenceProp` |  | The prop of this row. |

### ApiReferenceHeader

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### ApiReferenceTitle

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `level` | `2 \| 3 \| 4` | 3 | The heading level. Default 3. |

### ApiReferenceElement

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `lang` | `string` |  | Highlight the text in this language (a name or alias that `highlighter` knows). Works when the children are text (strings and numbers). Without it the code is plain ink. |
| `palette` | `"color" \| "ink" \| "theme"` |  |  |
| `size` | `"default" \| "xs"` |  |  |

### ApiReferenceDescription

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### ApiReferenceTable

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `children` | `ReactNode` |  | The row groups. With none: the own props, the inherited props, and the `...props` row. |

### ApiReferenceOwnProps

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `collapseAfter` | `number` | Number.POSITIVE_INFINITY | How many rows show before the fold. Default: all of them. |

### ApiReferenceInherited

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `collapseAfter` | `number` | 3 | How many rows show before the fold. Default 3. |

### ApiReferenceRest

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### ApiReference

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `part` | `ApiReferencePartData` |  | The part to show: the extractor's output for one part, or data you write or map. |
| `idPrefix` | `string` |  | The anchor id of each prop is `<idPrefix>-<prop>`. Default: the part name, lower case, spaces as `-`. |
| `labels` | `Partial<typeof API_REFERENCE_LABELS>` |  | The words of the table, for another language. Keep the object stable. |

### ApiReferenceKeyboard

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `keys` | `readonly ApiReferenceKey[]` |  |  |
| `labels` | `Partial<{ label: string; or: string; }>` |  |  |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| ApiReferenceRow | `api-reference-row` |  |  |  |
| ApiReferenceHeader | `api-reference-header` |  |  |  |
| ApiReferenceTitle | `api-reference-title` |  |  |  |
| ApiReferenceElement | `api-reference-element` |  |  |  |
| ApiReferenceDescription | `api-reference-description` |  |  |  |
| ApiReferenceTable | `api-reference-table` |  |  |  |
| ApiReferenceInherited | `api-reference-inherited` |  |  | `hit-area` |
| ApiReferenceRest | `api-reference-rest` |  |  |  |
| ApiReference | `api-reference` |  |  |  |
| ApiReferenceKeyboard | `api-reference-keyboard` |  |  |  |

## Usage

Map your docs data to one `ApiReferencePartData` per part, then render it.

```tsx title="button-docs.tsx"
import { ApiReference, ApiReferenceKeyboard } from "@/components/pro/code/api-reference";
import type { ApiReferencePartData } from "@/lib/pro/api-reference-model";

const BUTTON: ApiReferencePartData = {
  name: "Button",
  element: "button",
  props: [
    {
      name: "variant",
      type: '"default" | "outline" | "ghost"',
      values: ['"default"', '"outline"', '"ghost"'],
      default: '"default"',
      description: "The look of the button.",
    },
  ],
  rest: { element: "button", ref: true },
};

export function ButtonDocs() {
  return (
    <>
      <ApiReference part={BUTTON} />
      <ApiReferenceKeyboard keys={[{ keys: ["Enter", "Space"], description: "Presses the button." }]} />
    </>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui-pro/api-reference
```

It adds 87 registry items: 81 files, 14307 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `@phosphor-icons/react`, `@tanstack/highlight`, `@xstate/react`, `clsx`, `motion`, `tailwind-merge`, `tailwind-variants`, `xstate`.

## Built on

- [Badge](https://gelatinui.com/components/badge.md)
- [Button](https://gelatinui.com/components/button.md)
- [Code](https://gelatinui.com/components/code.md)
- [Code Block](https://gelatinui.com/components/code-block.md)
- [Collapsible](https://gelatinui.com/components/collapsible.md)
- [Kbd](https://gelatinui.com/components/kbd.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Code Block](https://gelatinui.com/components/code-block.md)
- [Code](https://gelatinui.com/components/code.md)
- [Kbd](https://gelatinui.com/components/kbd.md)
- [Table of Contents](https://gelatinui.com/components/table-of-contents.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Tab | Moves focus to each prop link, each type that opens, the fold button, and the docs link. |
| Enter, Space | Opens or closes the full type, or the folded rows. |

## Accessibility

Each part is a real `table` with a name (`Switch props`) and row headers on the prop names.

Folded rows stay in the page with `hidden="until-found"`, so find in page opens them.

The name of a type that opens starts with the visible type (`function, full type of onCheckedChange`).
