hp-demo
Documentation envelope used to wrap each example on a component doc page. A faint hex
backdrop sits behind the demo so transparent elements read clearly; an action bar carries
the "copy code" button; the slotted code area shows the source. Authoring is a default
slot for the rendered demo plus a code-named slot for a
<pre><code> block.
Bare envelope
With caption
No copy button
Install
bun add @hexpunk/core lit import "@hexpunk/core"; Properties
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
caption | caption | string | undefined | — | Optional caption shown above the demo (e.g., "Default", "Sizes", "Active state"). Leave empty for a bare envelope. |
noCopy | no-copy | boolean | false | Suppress the Copy code button. |
noThemeToggle | no-theme-toggle | boolean | false | Suppress the per-demo theme toggle. |
Slots
| Slot | Description |
|---|---|
(default) | Rendered demo element(s) (the foreground) |
code | <pre><code> block showing the source |
CSS Parts
| Part | Description |
|---|---|
caption | The caption strip (when set) |
preview | The preview area with backdrop |
actions | The footer toolbar with the Copy button |
code | The code area |
When to use
Accessibility
The copy button has aria-label="Copy code"; the "copied" confirmation is an
aria-live="polite" region so screen readers announce after a successful
copy. The backdrop is decorative and inherits hp-background's aria-hidden.
- 0.1.0-beta 2026-05-24
Added
- Showcase: right-rail TOC walker skips headings inside
<hp-demo>blocks (demo content is sample, not page structure) and headings carryingdata-no-tocfor one-off opt-outs. - Showcase:
/getting-started/elements— preflight tour walking every styled primitive inside<hp-demo>blocks, with hp-banner callouts pointing to the<hp-*>component upgrade path for code, dividers, and form elements. <hp-copy>— copy-to-clipboard button widget. Lucidecopyicon + slotted label (translatable per-instance, default "Copy") + sibling "Copied" toast witharia-live="polite".valueattribute for the text to copy;copiedattribute for the toast text;icon-onlyboolean drops the visible label while keeping it in the a11y tree. Bubblinghp-copy-success/hp-copy-errorevents. Async Clipboard API only — noexecCommandfallback. Now powers<hp-demo>'s copy-code action and<hp-latex>'s source-copy button.
Changed
<hp-demo>copy action — replaced the bespoke inline copy button + animated toast with<hp-copy>so the same widget powers both<hp-demo>and<hp-latex>. Slot-text source caching viaslotchangeon the code slot; no behaviour change for consumers.
- Showcase: right-rail TOC walker skips headings inside