Skip to content
Klarhimmel UI

Docs, preview frame

Docs, preview frame previewDocs, preview frame preview

Install

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

A framed live stage and its code, with Preview and Code tabs when both are present. md, preview-only expected result).

Import

Import

import Block from '@/components/klarhimmel/blocks/docs-preview-frame';
Also called
  • docs/preview-frame
About
A framed live stage and its code, with Preview and Code tabs when both are present. The stage is a live demo (demo id) or an image; either part may be left out (code-only SKILL.md, preview-only expected result).
Category
Documentation sections: headers, install panels, props tables, previews. New project? Set it up once: /get-started/installation.

Notes

When to use it

A single framed stage with its code, switching between Preview and Code tabs when both exist. Use docs-examples for several named variations and docs-anatomy when the parts need explaining.

Writing for it

- Title is capped at 80 characters and the description at 300. Say what the reader is looking at, such as the finished page or the file to save. - Code holds 2000 characters and an optional filename of 60; give the filename when the file location matters, such as a skill or config file. - Set a demo id for a live stage or an image for a static one. Either part can be left out for a code-only or preview-only frame.

Watch out for

The tab switch appears only when both a stage and code exist. With only one of them the frame shows it plainly, and if neither is set the frame is empty.

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 DocsPreviewFrame from '@/components/klarhimmel/blocks/docs-preview-frame';

export default function Section() {
  return (
    <Theme theme="brand">
      <BlockSurface>
        <DocsPreviewFrame props={{
          "title": "Name this use",
          "description": "Say in one or two sentences how to use it and what to choose for the main case.",
          "preview": {
            "src": "/pictures/photo-key2.avif",
            "alt": "A key in the lock of a green door"
          },
          "demo": "button-variants",
          "filename": "example.tsx",
          "code": "import { Component } from '@your/ui';\n\nexport function Actions() {\n  return (\n    <div className=\"flex gap-3\">\n      <Component>Main action</Component>\n      <Component option=\"second\">Second action</Component>\n    </div>\n  );\n}"
        }} />
      </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 this use'Text, up to 80 characters.
descriptionstring'Say in one or two sentences how to …'Text, up to 300 characters.
previewMedia{…}Optional; empty is not rendered.
demostring'button-variants'Text, up to 80 characters. Optional; empty is not rendered.
filenamestring'example.tsx'Text, up to 60 characters. Optional; empty is not rendered.
codestring'import { Component } from '@your/ui…'Text, up to 2000 characters. Optional; empty is not rendered.
headingLevel'1' | '2'-One of '1', '2'. Optional; empty is not rendered.