Skip to content
Klarhimmel UI

Docs, examples

Docs, examples previewDocs, examples preview

Install

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

Named example groups (Variants, Sizes, States, With icon, Composition), each a stage (live demo or image) with optional code beneath.

Import

Import

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

Notes

When to use it

Stacks named example groups such as Variants, Sizes and States, each a stage with its code underneath. Use docs-preview-frame when there is only one example and a Preview and Code switch is enough.

Writing for it

- Group titles hold 40 characters and render as h3 under the block heading, so name the single thing that changes, like Sizes or With icon. - Code is allowed up to 2400 characters per group, which fits a whole demo including its imports. Leave it empty for groups where the picture says it all. - Order the groups from the default case to the edge cases, and use the group description (200 characters) to say when to choose that variant.

Watch out for

A group without code gets no code panel at all when published, so the stage sits alone in its frame. Between 1 and 8 groups are allowed, and a long page of them is better split into two blocks.

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 DocsExamples from '@/components/klarhimmel/blocks/docs-examples';

export default function Section() {
  return (
    <Theme theme="brand">
      <BlockSurface>
        <DocsExamples props={{
          "title": "Name the set",
          "description": "Say what each group changes, in one line",
          "groups": [
            {
              "title": "First group",
              "description": "Say what this group shows and when to use it",
              "preview": {
                "src": "/pictures/photo-lily1.avif",
                "alt": "A white lily in soft light"
              },
              "demo": "button-variants",
              "code": "<Component>First</Component>\n<Component option=\"second\">Second</Component>\n<Component option=\"third\">Third</Component>"
            },
            {
              "title": "Second group",
              "description": "Say what this group shows and when to use it",
              "preview": {
                "src": "/pictures/photo-optic1.avif",
                "alt": "Silver-framed glasses on a white table"
              },
              "demo": "button-sizes",
              "code": "<Component size=\"a\">First</Component>\n<Component size=\"b\">Second</Component>\n<Component size=\"c\">Third</Component>"
            },
            {
              "title": "Third group",
              "description": "Say what this group shows, when to use it and what to watch for",
              "preview": {
                "src": "/pictures/photo-party1.avif",
                "alt": "A party table with a cake and balloons"
              },
              "demo": "button-states",
              "code": ""
            }
          ]
        }} />
      </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 set'Text, up to 60 characters.
descriptionstring'Say what each group changes, in one…'Text, up to 200 characters.
groups{ title, description, preview, demo, code }[]3 itemsList of 1 to 8. Each item: title, description, preview (optional), demo (optional), code.
headingLevel'1' | '2'-One of '1', '2'. Optional; empty is not rendered.