GhostCodeBlock reference
Package: @ghostvue/themes. Status: experimental (stability policy).
Themed code block around @ghostvue/vue GhostCodeBlock: subtle surface, hairline border, muted header with the title and language, quiet Copy and fold buttons on the small control size, a CSS-painted check while copied, the failure text in the danger color under the header, the mono type token with a numeric line height so the fold shows exactly foldLines lines, and a fade over the last visible line while collapsed (removed under reduced transparency and forced colors). Same props, events, slots and exposed members as the headless component; behavior and accessibility come from it.
Generated from the component manifest. Edit the manifest or Vue source, then rebuild the docs.
Props
None declared.
Emits
| Name | Payload | Description |
|---|---|---|
copySettled | GhostCodeBlockCopySettledEvent | Forwarded copySettled event. |
Models
| Prop | Event | Type | Description |
|---|---|---|---|
expanded | update:expanded | boolean | v-model:expanded binding for the fold state. |
Slots
| Name | Description |
|---|---|
default | Forwarded default slot: highlighted markup inside the code part. |
title | Forwarded title slot. |
actions | Forwarded actions slot with copy and state. |
copy | Forwarded copy slot with state. |
Slot props: default
None declared.
Slot props: title
None declared.
Slot props: actions
None declared.
Slot props: copy
None declared.
Exposed members
| Name | Type | Description |
|---|---|---|
element | HTMLElement | null | Root of the inner headless component. |
copy | () => Promise<boolean> | Runs the inner component's copy, including the failure fallback. |
Parts and data attributes
| Attribute | Value | Description |
|---|---|---|
data-part | root | Headless root (ghost-code-block) inside a block div.ghost-themed-scope wrapper. The recipe reaches the header, copy, status, viewport, code and fold-toggle parts through child combinators only. |
CSS variables
| Name | Description |
|---|---|
--ghost-type-family-mono | Code font family. |
--ghost-surface-subtle-bg | Block surface and the collapsed fade color. |
--ghost-border-default | Block border and header separator. |
--ghost-text-danger | Failure text color. |
Accessibility
Role: generic. APG pattern: https://www.w3.org/WAI/ARIA/apg/practices/landmark-regions/.
Required ARIA attributes: none.
Keyboard
None declared.
Verification
Each category is reviewed separately. Automated keyboard and axe results do not attest manual or assistive-technology review.
| Category | Status | Evidence |
|---|---|---|
| Automated keyboard | Not reviewed | No declared key is mapped to a browser test yet. |
| Manual interaction | Not reviewed | No review recorded. |
| Assistive technology | Not reviewed | No review recorded. |
Examples
code-block/highlighted
A TypeScript file rendered from consumer-highlighted tokens with a file name header, Copy, horizontal scroll for a long line, and a fold after eight lines.
code-block/shell
Install commands whose $ prompts render but are left out of the copied text through copyText, with an icon in the copy slot.
code-block/actions
An Open in playground link and an icon-only custom Copy button in the actions slot, with the built-in button removed and copySettled recording the last result.
code-block/copy-invite-link
useGhostClipboard on an ordinary button outside a code block, announcing the result in GhostVisuallyHidden and showing the failure next to the field.