GhostCard
GhostCard is a composable surface with optional header, content, and footer parts. Use it for dashboard tiles, catalog items, and settings panels. The consumer owns layout inside each part; the primitive supplies stable hooks and optional ambient spotlight via useGhostInteractiveSurface.
Import it from @ghostvue/themes for default surface chrome. To style your own cards, see Advanced: headless composition.
Project summary cards
Responsive two-card grid comparing an action card whose footer link and Deploy button act in place with a whole-card spotlight link.
Two themed GhostCard surfaces from @ghostvue/themes show the two card patterns side by side, in one column on narrow previews and two columns from 34rem (@container ghost-demo):
- Northwind Web is a static
articlewith its controls in#footer. View logs is a link to the deployment's logs and Deploy queues a deploy and reports it in a status line inside the card. - Deployment runbook is
as="a"withhrefandinteractive="spotlight". The whole card is one link and contains no other controls.
Parts render only when their slots have content. The default root is article.
Actions in the footer
Keep the root non-interactive when the card holds its own links or buttons, as the Northwind Web card does. Each footer control is its own tab stop, and the card announces as an article rather than as one large control. Report the result of an in-place action, such as the queued deploy, in a status line that stays mounted so the new text is announced.
Clickable (navigational) card
When as="a" with href, the entire card is one link, like the Deployment runbook card. Do not nest buttons or other links in header, content, or footer—that violates the interactive content model and fails accessibility checks. Secondary actions belong on a sibling surface or outside the link card.
Accessible patterns
- Navigate:
as="a"+hrefon the root; slots contain only static markup. - Act in place: default
article/divroot; putGhostButtonor links in#footeror#content. - Spotlight only:
effects={['spotlight']}or themedinteractive="spotlight"adds decoration; it does not make the card focusable.
Ambient spotlight
Elevation chrome and optional spotlight from themes.
Themed interactive="spotlight" tracks the pointer across the card. Pointer tracking uses data-interactive-state so a future data-state on the card is reserved for consumer semantics.
Themed props
@ghostvue/themes adds these to the headless GhostCard API, which it forwards:
| Prop | Type | Default | Description |
|---|---|---|---|
interactive | 'spotlight' | null | Opt-in ambient spotlight on the card. |
The themed wrapper sets data-themed on the inner root.
Accessibility
- Prefer native
article,a, orbuttonover invented roles. - Never nest interactive elements inside an
aorbuttoncard root. - The spotlight glow is
aria-hidden; reduced motion disables tracking.
See the specification for the full contract.
Advanced: headless composition
For teams that bring their own design system, the headless GhostCard from @ghostvue/vue renders the same parts and roots with no surface chrome.
Basic use
Header, content, and footer parts on a surface.
Headless footer actions
Static root and footer buttons.
Headless navigational card
Whole-card link without nested interactives.
Headless spotlight
Ambient pointer tracking on the card root.
Composable
useGhostCard returns as, rootProps, and isActionRoot for custom hosts. The GhostCard reference page renders the card/composable example with its source.
API
| Prop | Type | Default | Description |
|---|---|---|---|
as | GhostCardElement | "article" | Root element. Use a only when the whole card navigates without nested controls. |
effects | 'spotlight'[] | "[]" | Ambient spotlight recipes. Empty list keeps the card inert. |
| Slot | Slot props | Description |
|---|---|---|
default | — | Primary body; rendered in data-part="content". |
footer | — | Optional bottom region for actions on static roots. |
header | — | Optional top region. |
Native attributes fall through to the root. The component sets class, data-ghost-card, data-part="root", and spotlight hooks when enabled.
The root exposes element: HTMLElement | null through a template ref.