Skip to content
Klarhimmel UI

Docs, props table

Docs, props table previewDocs, props table preview

Install

npx shadcn add @klarhimmel/docs-props-table
DetailsAbout, usage, props and more

A table of a component API: name, type, default and description. Scrolls sideways in narrow containers.

Import

Import

import Block from '@/components/klarhimmel/blocks/docs-props-table';
Also called
  • docs/props-table
Category
Documentation sections: headers, install panels, props tables, previews. New project? Set it up once: /get-started/installation.

Notes

When to use it

A table of a component API with name, type, default and description columns. For tables with other columns, such as keys or tokens, use docs-table.

Writing for it

- Rows hold a name of 40 characters, a type of 80, a default of 40 and a description of 400. Write the type as it appears in the source. - Write a dash or the literal default in the default column. Do not leave it blank, because the column is always drawn. - Keep the description to what the prop does, and list required props first; the table allows 1 to 30 rows.

Watch out for

The table is at least 40rem wide, so a narrow container scrolls it sideways. The scroll area can be focused by keyboard, and a hint line shows only on narrow containers.

Usage

The block in a page, with its default content (long lists shortened). Every prop is in the table below.

section.tsx
import { Theme } from '@/components/klarhimmel/theme/style';
import { BlockSurface } from '@/components/klarhimmel/blocks/surface';
import DocsPropsTable from '@/components/klarhimmel/blocks/docs-props-table';

export default function Section() {
  return (
    <Theme theme="brand">
      <BlockSurface>
        <DocsPropsTable props={{
          "title": "Name the API",
          "description": "Say in one or two sentences which fields are required and what else applies.",
          "rows": [
            {
              "name": "Field one",
              "type": "'first' | 'second' | 'third' | 'fourth'",
              "fallback": "'first'",
              "description": "Say what the field changes"
            },
            {
              "name": "Field two",
              "type": "'a' | 'b' | 'c'",
              "fallback": "'b'",
              "description": "Say what the field changes and its limits"
            },
            {
              "name": "Field three",
              "type": "Node type",
              "fallback": "-",
              "description": "Say what the field changes"
            },
            {
              "name": "Field four",
              "type": "Node type",
              "fallback": "-",
              "description": "Say what the field changes"
            },
            {
              "name": "Field five",
              "type": "boolean",
              "fallback": "false",
              "description": "Say what the field changes and its limits"
            },
            {
              "name": "Field six",
              "type": "boolean",
              "fallback": "false",
              "description": "Say what the field changes and its limits"
            }
          ]
        }} />
      </BlockSurface>
    </Theme>
  );
}

Props

The type, default and text limit of every prop. On a real page, over-limit text is kept and checkSections flags it (Installation, Check a page before you ship); this live preview shows the default until it fits. The panel above edits all props.

PropTypeDefaultDescription
titlestring'Name the API'Text, up to 80 characters.
descriptionstring'Say in one or two sentences which f…'Text, up to 300 characters.
rows{ name, type, fallback, description }[]6 itemsList of 1 to 30. Each item: name, type, fallback, description.
headingLevel'1' | '2'-One of '1', '2'. Optional; empty is not rendered.