Demo Label

The label under a piece in a demo or gallery, set in the mono face at 12px in the default text color so it reads as a note about the piece, never part of it.

Installation

npx shadcn@latest add @01orbital/demo-label

Usage

import { PlanetIcon } from "@phosphor-icons/react/ssr"

import { GlassIcon } from "@/components/graphics/glass-icon"
import { DemoLabel } from "@/components/text/demo-label"
import { Badge } from "@/components/ui/badge"
import { Kbd, KbdGroup } from "@/components/ui/kbd"

const COPY = {
  badge: "Published",
  badgeCaption: "Badge · outline",
  glassCaption: "Glass Icon · sm, 64px",
  modifier: "⌘",
  key: "K",
  keyboardCaption:
    "Keyboard shortcut · Command K, with a longer caption in a narrow layout.",
} as const

/** Captions under a badge, a glass icon on dark ink, and a keyboard shortcut. */
export default function DemoLabelDemo() {
  return (
    <div className="flex w-full max-w-3xl flex-wrap items-start gap-6 p-6">
      <div className="grid w-full min-w-0 justify-items-start gap-3 p-4 sm:w-48">
        <div className="flex h-16 items-center">
          <Badge variant="outline">{COPY.badge}</Badge>
        </div>
        <DemoLabel>{COPY.badgeCaption}</DemoLabel>
      </div>
      <div className="dark grid w-full min-w-0 justify-items-start gap-3 rounded-(--tile-radius) bg-scene p-4 text-scene-foreground sm:w-56">
        <GlassIcon size="sm" className="bg-blue-9/20">
          <PlanetIcon
            aria-hidden="true"
            className="text-blue-8"
            weight="regular"
          />
        </GlassIcon>
        <DemoLabel>{COPY.glassCaption}</DemoLabel>
      </div>
      <div className="grid w-full min-w-0 justify-items-start gap-3 p-4 sm:w-48">
        <div className="flex h-16 items-center">
          <KbdGroup>
            <Kbd>{COPY.modifier}</Kbd>
            <Kbd>{COPY.key}</Kbd>
          </KbdGroup>
        </div>
        <DemoLabel>{COPY.keyboardCaption}</DemoLabel>
      </div>
    </div>
  )
}

This example installs with everything it uses:

npx shadcn@latest add @01orbital/demo-label-demo

API reference

A caption under a demo or gallery piece, in medium-weight mono at 12px/20px. Long captions wrap with balanced last lines. The caption inherits its ground's text color; native paragraph props pass through.

It accepts the HTML attributes of the element it renders.

Dependencies

npm: cn. The CLI installs it for you.

Requires these pieces. The CLI adds each one that is missing and won't replace a file you already have unless you choose to:

  • font-geist-mono

Last updated on