Skip to content

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

Components

Free

Type Table for Radix UI

An API reference table for React on Radix UI: each prop's name and type in a row that opens to its description, default and parameters.

On this page9 sections

Radix UI does not include this primitive, so this page uses the Ark UI component. The visuals match the Ark UI version.

Type Table lists the props of a component or the options of a function, one row each, with the name and type always in view. Opening a row shows its description, default, parameters and return type, so a long API stays short until the reader needs one detail.

For records people scan across columns, use a Table. For a list of shortcuts, use a Keyboard Table.

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.

Anatomy

Type Table anatomy: name, type, header, item, default

Usage

import { TypeTable, TypeTableItem } from "@/components/ui/type-table";

A row's name is also its value, so defaultValue on the table lists the names of the rows that start open.

<TypeTable defaultValue={["multiple"]}>
  <TypeTableItem defaultValue="true" name="multiple" optional type="boolean">
    Allow more than one row to be expanded.
  </TypeTableItem>
  <TypeTableItem name="value" optional type="string[]">
    Controlled expanded item values.
  </TypeTableItem>
  <TypeTableItem
    name="onValueChange"
    optional
    parameters={[{ description: "{ value: string[] }", name: "details" }]}
    returns="void"
    type="(details: { value: string[] }) => void"
  >
    Called when expanded items change.
  </TypeTableItem>
</TypeTable>

Accessibility

Type Table is built on Ark UI's accordion on every base, so it behaves the same everywhere. A row with something to show is a button that reports aria-expanded, and its panel is a region labeled by that row. A row with nothing to open is plain text and takes no focus. The Prop and Type header is text, not a table header, so a screen reader hears each row's name and type as its button label. A deprecated row adds the word deprecated after its name in that label, hidden from sight, so the strikethrough isn't the only sign.

Space
When focus is on a row, opens its details, or closes them when they are open.
Enter
When focus is on a row, opens its details, or closes them when they are open.
Tab
Moves focus to the next focusable element.
Shift+Tab
Moves focus to the previous focusable element.
Arrow Down
Moves focus to the next row that opens, and from the last one back to the first.
Arrow Up
Moves focus to the previous row that opens, and from the first one to the last.
Home
Moves focus to the first row that opens.
End
Moves focus to the last row that opens.

Demos

Controlled

The open rows live in the demo's own state, passed as value and updated from onValueChange, and the line under the table prints their names, or none once every row is closed. The value row starts open. Hold the open rows yourself when a link or a search box elsewhere on the page should open a specific prop.

Preview width

Deprecated

The open prop has deprecated, which strikes its name through, fades it and tells screen readers it is deprecated, and its description points to value and defaultValue instead. Keep a row like this while old code still passes the prop and readers need the way out. Remove it once the prop is gone from every version people still run.

Preview width

Disabled

The middle row has disabled on its TypeTableItem, so it is faded to half opacity and can't be focused, hovered or opened, while the value and className rows open as usual. Its description never shows. Disable a row only when its details don't apply to the reader, since nobody can reach them.

Preview width

Optional

The id row is required, so its name has no mark, while label and disabled carry optional and print a question mark after the name. The disabled row also has a defaultValue of false, shown as Default when it opens. Mark every prop a caller can leave out, so the required ones stand out.

Preview width

Single

multiple is set to false, so opening one of the three rows closes the one that was open, and pressing the open row closes it too. Use it when descriptions run long and two open at once would push the next prop off screen. Keep the default, several open rows, when readers compare props.

Preview width

Size compact

The same three rows with size set to compact, which trims the padding of the header and of every row, so these rows are a quarter shorter than in the other demos. Pick it for a reference with many props in a sidebar or a dialog. Keep the default when the table is the main content of the page.

Preview width

FAQ

When should I use a Type Table instead of a regular Table?

Use a Type Table for an API: props, options or fields where the name and type are what people scan for, and the description is something they open when they need it. Each row carries its own details, so a list of 30 props stays one line per prop.

Use a Table for records, such as orders or users, where people compare values across columns, sort them or read every cell. A Type Table has exactly two visible columns and no sorting.

How do I document a prop in the Type Table?

Add a TypeTableItem with its name and type, and write the description inside it. optional adds a question mark after the name, defaultValue shows a Default line when the row opens, and deprecated strikes the name through, as the Optional and Deprecated demos show.

The type column cuts off a long type, so a type over 32 characters, or any union, intersection, generic or arrow function type (one with |, &, < or > in it), is repeated in full when the row opens. typeDescription replaces that full text, and nameColumn on the table renames the Prop header. typeDescriptionLink links the type on the open row's Type line, or in the column of a row with nothing to open.

How do I show a function's parameters and return type in the Type Table?

Set parameters on the TypeTableItem to a list of objects, each with a name and a description, and returns to the return type. The open row lists them under Parameters and Returns, after the description.

Give the item the whole signature as its type too, such as the onValueChange row in the first preview. Because the signature holds an arrow, the open row repeats it in full under Type, while the column shows as much as fits.

How do I control which Type Table rows are open in React?

Hold the open rows in state, pass them as value and update them in onValueChange, which receives an object, so read the array from details.value. The Controlled demo does exactly this.

Each entry is a row's name, or its value when you set one. To start some rows open and leave the rest to the reader, list them in defaultValue instead. Set multiple to false to keep one row open at a time, as the Single demo does.

Why do two Type Table rows open and close together?

They share a name. A row's value is its name unless you set value, and the table keeps track of open rows by value, so two rows called value, for the root and for an item, open and close as one.

Give one of them a value of its own, such as item-value. The name in the first column stays the same, and defaultValue or your own state then lists that new value for the row.

Why can't Ctrl+F find text inside a closed Type Table row?

A closed row's details aren't in the page. The component sets lazyMount and unmountOnExit on its accordion after your own props, so the panel is only rendered while the row is open, and a prop can't change that.

Names and types are always rendered, so find in page still lands on the right row. On a reference page where people search descriptions, start every row open by listing all the names in defaultValue, or put an Expand all button above the table that sets value to every name.

Why does the Type column disappear in a narrow Type Table?

Below 20rem wide, the table hides the Type column and its header so the names keep their room. It measures its own width, not the window's, so a Type Table in a slim sidebar hides types even on a wide screen.

Long and compound types still show in full when the row opens. A short plain one, such as boolean, then appears nowhere, so set typeDescription on rows where the type matters, and it shows whenever that row opens.

API Reference

TypeTable

<div> data-slot="type-table"

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. Ark default: false.

Default
true
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 }
lazyMount?boolean

Whether to enable lazy mounting.

Default
false
multiple?boolean

Allow more than one row to be expanded.

Default
true
nameColumn?string

Label for the first column.

Default
"Prop"
onFocusChange?(details: FocusChangeDetails) → void

The callback fired when the focused accordion item changes.

Type
(details: FocusChangeDetails) → void
Parameters

details – { value: string | null }

Returns
void
size?"default" | "compact"

Row density. Compact reduces trigger padding.

Type
"default" | "compact"
Default
"default"
unmountOnExit?boolean

Whether to unmount on exit.

Default
false
asChild?boolean

Merge props onto the child element instead of rendering a host.

className?string

Merged with the part's classes.

AttributeType
data-orientationstring

The orientation of the accordion.

data-size?string

Mirrors size.

TypeTableItem

<div> data-slot="accordion-item"

PropType
valuestring

The value of the accordion item.

disabled?boolean

Whether the accordion item is disabled.

asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

AttributeType
data-disabled?string

Present when disabled.

data-focus?string

Present when focused.

data-orientation?string

The orientation of the item.

data-state"open" | "closed"

"open" or "closed".

Type
"open" | "closed"

TypeTableItemTrigger

<button> data-slot="accordion-trigger"

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

AttributeType
data-controls?string
data-focus?string

Present when focused.

data-orientation?string

The orientation of the item.

data-state"open" | "closed"

"open" or "closed".

Type
"open" | "closed"

TypeTableItemContent

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

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

AttributeType
data-disabled?string

Present when disabled.

data-focus?string

Present when focused.

data-orientation?string

The orientation of the item.

data-state"open" | "closed"

"open" or "closed".

Type
"open" | "closed"

TypeTableContext

TypeTableItemContext