# Props Table

- Page: <https://kznlabs.github.io/labsUI/components/props-table>

## Props Table (`props-table`, component)

The props or options of a component or function from rows of data: name, type, default and a description where backticks become code. A table, or a list where the container is too narrow for one. Server-safe.

- Install: `npx @kznlabs/labsui add props-table`
- Docs: <https://kznlabs.github.io/labsUI/components/props-table>
- Brings: overflow-focus, table, utils
- npm: clsx@^2.1.1, lucide-react@1.63.0, tailwind-merge@^3.7.0

### API

- `inlineCode(text: string) => ReactNode`: Text with its `backticks` turned into inline code and its line breaks into spaces.
- `<PropsTable>` (+ <div> props): The props or options of a component or function: a table, or a list where the container is too
narrow for one. Server-safe.
  - `label: string`: Accessible name of the list shown in a narrow container.
  - `rows: PropsTableRow[]`: One row per prop or option.
  - `labels?: { name?: string | undefined; type?: string | undefined; default?: string | undefined; }`: Column headings, e.g. `{ name: "Option" }` for a function's options.
  - `requiredLabel?: string` = `"required"`: Explains the star on required rows.

- `type PropsTableRow = { name: string; type: string; required?: boolean; default?: string; description?: ReactNode; }`

### Usage

```tsx
<PropsTable label="Retry options" labels={{ name: "Option" }} rows={[{ name: "attempts", type: "number", default: "3", description: "Tries before giving up." }, { name: "signal", type: "AbortSignal", required: true }]} />
```

### Example: retry-options.tsx

```tsx
import { PropsTable } from "@/components/ui/props-table";

export function RetryOptions() {
  return (
    <PropsTable
      label="Retry options"
      labels={{ name: "Option" }}
      rows={[
        {
          name: "signal",
          type: "AbortSignal",
          required: true,
          description: "Stops waiting between tries.",
        },
        {
          name: "attempts",
          type: "number",
          default: "3",
          description: "Tries before giving up.",
        },
      ]}
    />
  );
}
```
