Skip to content
Klarhimmel UI

Directory, preview

Directory, preview previewDirectory, preview preview

Install

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

Full-width preview of one block or screen: breadcrumbs, title, status badge, viewport toggle, Preview and Code tabs, actions and a framed stage that renders a…

Import

Import

import Block from '@/components/klarhimmel/blocks/directory-preview';
Also called
  • directory/preview
About
Full-width preview of one block or screen: breadcrumbs, title, status badge, viewport toggle, Preview and Code tabs, actions and a framed stage that renders a registered demo by id.
Category
Catalogue pages: headers with filters, card grids, full-width previews. New project? Set it up once: /get-started/installation.

Notes

When to use it

A full-width view of one block or screen, with title, status, viewport toggle and Preview and Code tabs. For a list of items to pick from use directory-cards.

Writing for it

- The title holds 80 characters and the status 24. The description holds 200 and can name the layout in one sentence. - Viewports take up to 3 labels of 20 characters, such as Desktop, Tablet and Mobile, in that order; the first is the full width. - Set a demo id for the stage, or fall back to an image. Code holds 2000 characters and the tabs are limited to two, usually Preview and Code.

Watch out for

The Code tab exists only when two tabs are written; with one tab the code is not shown. The title here is an h2, not an h1, so the page needs its heading from another block.

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 DirectoryPreview from '@/components/klarhimmel/blocks/directory-preview';

export default function Section() {
  return (
    <Theme theme="brand">
      <BlockSurface>
        <DirectoryPreview props={{
          "breadcrumbs": [
            {
              "label": "First page",
              "href": "/catalogue/blocks/"
            },
            {
              "label": "Second page",
              "href": "/catalogue/blocks/hero/"
            },
            {
              "label": "Current page",
              "href": ""
            }
          ],
          "title": "Name what is shown",
          "status": "Free",
          "description": "Say in one sentence what it is, how it is laid out and when to use it.",
          "viewports": [
            "Wide view",
            "Mid view",
            "Narrow view"
          ],
          "tabs": [
            "First tab",
            "Second tab"
          ],
          "actions": [
            {
              "label": "Main action",
              "href": "#copy"
            }
          ],
          "demo": "hero-split-sample",
          "preview": {
            "src": "/pictures/photo-gelato1.avif",
            "alt": "Tubs of gelato in a display case"
          },
          "code": "import Block from '@/blocks/your-block';\n\nexport default function Page() {\n  return (\n    <Block\n      props={{\n        title: 'Say what the page offers',\n        primary: { label: 'Main action', href: '#go' },\n      }}\n    />\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
breadcrumbsLink[]3 itemsList of up to 4.
titlestring'Name what is shown'Text, up to 80 characters.
statusstring'Free'Text, up to 24 characters.
descriptionstring'Say in one sentence what it is, how…'Text, up to 200 characters.
viewportsstring[]3 itemsList of up to 3.
tabsstring[]2 itemsList of up to 2.
actionsLink[]1 itemList of up to 3.
demostring'hero-split-sample'Text, up to 80 characters.
previewMedia{…}See the type.
codestring'import Block from '@/blocks/your-bl…'Text, up to 2000 characters.
headingLevel'1' | '2'-One of '1', '2'. Optional; empty is not rendered.