GhostInlineAlert specification
Status: Proposed for GHO-76 implementation scope. Approval is PR review of this spec together with the implementation.
Purpose and user problems
GhostInlineAlert is inline contextual feedback for errors, warnings, and recoverable failures near the content they describe. Immediate DataTable uses include row-load failures, mutation failures, and retryable table errors shown above or inside a table region. Sighted users see a compact title, message, and optional action controls. Assistive technology reads the same copy in document order, with role="status" or role="alert" only when the consumer opts in for content that appears or updates after mount.
Non-goals
- Global notification management, toasts, snackbars, or stacked notification lists. Use a future
GhostToast/ provider for transient global feedback. - Dismissible chrome, auto-timeout, or swipe-to-dismiss. Consumers own removal with
v-ifand their own close buttons if needed. - Fixed severity or status enums (
variant="error",type="warning"). Headless styling hooks and themedtoneexpress color intent; meaning lives in slot copy. - Replacing
GhostFieldErrorinsideGhostField. Field validation errors stay on the field primitive. useControllableState— there is no model.- A parallel styling-hooks vocabulary beyond ADR 0004 (
data-part, class, omitted-defaultdata-*visual hooks).
Public API
Props and configuration
Headless @ghostvue/vue GhostInlineAlert / useGhostInlineAlert:
| Prop | Type | Default | Contract |
|---|---|---|---|
announce | 'off' | 'status' | 'alert' | 'off' | Live-region semantics. off is static feedback with no role. status sets role="status" (polite). alert sets role="alert" (assertive). Use status/alert only for copy that appears or changes after mount, not for always-present page chrome. |
headingLevel | 1 | 2 | 3 | 4 | 5 | 6 | 3 | Level of the native heading wrapping the #title slot. Omitted #title skips the heading. |
as | GhostInlineAlertElement | 'div' | Root element. Prefer div inside table cells; use section when the alert is a named landmark. |
type GhostInlineAlertElement = 'div' | 'section'
type GhostInlineAlertHeadingLevel = 1 | 2 | 3 | 4 | 5 | 6
type GhostInlineAlertAnnounce = 'off' | 'status' | 'alert'Named ESM exports: GhostInlineAlert, useGhostInlineAlert, and the types above. Headless behavior lives in the composable; the SFC renders the root, named slots, and part wrappers.
Native attributes and event listeners fall through to the root. useGhostId('ghost-inline-alert-title') supplies the title heading id when the #title slot is rendered. When #title is present, as is section, and announce is off, the root receives aria-labelledby pointing at that id. Default div roots never get aria-labelledby (generic div has no nameable role). When announce is status or alert, the root receives the matching role and does not also use aria-labelledby on the same node.
v-model contracts
There is no model. Visibility, copy, and live semantics are consumer-owned.
Events, callbacks, slots, and exposed methods
| Slot | Part element | Contract |
|---|---|---|
title | title | Optional short heading. Rendered as h{headingLevel} with generated id. |
message | message | Primary supporting copy. Rendered in a <div> so paragraphs and lists are valid. |
actions | actions | Optional action controls (e.g. GhostButton). Children remain focusable; the root is not. |
No default slot. No component-specific events. Template ref exposes:
element: HTMLElement | null— the root host after mount.
Themed @ghostvue/themes GhostInlineAlert
Wraps the unstyled component. Behavioral props pass through. Visual props:
| Prop | Type | Default | Contract |
|---|---|---|---|
variant | 'solid' | 'soft' | 'outline' | 'ghost' | 'soft' | Visual treatment (same set as GhostBadge). |
tone | 'accent' | 'neutral' | 'danger' | 'success' | 'warning' | 'neutral' | Semantic color intent, independent of variant. Not a status enum. success and warning follow the status tone amendment. |
Sets data-themed on the inner root (same pattern as GhostEmptyState). Sets data-variant / data-tone when not the default so CSS can treat omitted hooks as soft / neutral.
State model
Stateless presentational markup. No data-state. Live behavior is entirely from the announce prop and consumer mount timing.
Loading, empty, disabled, read-only, and error states
None apply as component states. Consumers mount the alert when they have copy to show. Loading indicators belong to GhostSpinner / GhostSkeleton siblings.
Async behavior
The component performs no async work. For failures after fetch, consumers typically mount the alert with announce="alert" or toggle announce when copy appears. The primitive does not detect “after mount” automatically; misuse of announce on static initial content is a consumer documentation issue.
Consumer data
No data props and no mutation. Slot content is consumer-owned.
Accessibility contract
Semantics and relationships
DOM reading order: #title, #message, #actions.
The title uses a native heading when the slot is present. Message copy is ordinary text in a div with data-part="message".
When announce is off, the root has no live-region role. With #title and as="section", aria-labelledby names the section.
When announce is status, the root is role="status" (implicit aria-live="polite"). When announce is alert, the root is role="alert" (implicit aria-live="assertive").
Choose status for recoverable or informational updates; choose alert for urgent errors that need immediate attention. Do not set announce to status or alert for copy that is present in the initial HTML with no later change unless the surrounding workflow intentionally wants a mount announcement.
Interactive controls live only in #actions. They are not part of the root accessible name unless named normally as buttons or links.
Keyboard interaction
No root key handling. #actions children keep normal tab order.
Focus behavior
The root is not focusable. Actions remain focusable when present.
Assistive technology expectations
Static alerts (announce="off") are read in document order like surrounding content. Live alerts announce their subtree when inserted or when the root role changes from a non-live configuration to status/alert as supported by the platform. The component does not move focus when an alert appears.
Rendering and customization
Slots and fallthrough attributes are the headless customization API. Stable hooks:
- class
ghost-inline-alert data-part="root"on the hostdata-part="title" | "message" | "actions"on slot wrappersdata-ghost-inline-alert=""on the root for instance queries- no
data-stateat introduction
Themed recipe CSS applies under .ghost-theme, .ghost-themed-scope, or [data-themed] on the root. Layout is inline-start block flow (not centered like GhostEmptyState).
Environment behavior
SSR and hydration
Markup is deterministic from props and slot presence. Generated title ids come from useGhostId and must match between server and client (covered by expectSsrHydration). The exposed element is null until mount.
Mobile and touch
No gestures. Action buttons inside #actions own touch target size when using GhostButton.
Performance
Constant-time render. No listeners or observers.
Composition
useGhostInlineAlert owns root bindings. Unstyled GhostInlineAlert composes useGhostId. Optional actions compose with GhostButton. No overlay or portal primitives.
Machine-readable contracts: packages/vue/manifests/ghost-inline-alert.manifest.json and packages/themes/manifests/ghost-inline-alert.manifest.json.
Test plan
- Vue unit tests: default markup,
announceroles, sectionaria-labelledbyonly whenannounceisoff, slots and part order, fallthrough, exposedelement, composable contract, and SSRrenderToString. - SSR hydration:
expectSsrHydrationfor title id stability. - Compile-time tests for props and exposed ref.
- Integration tests for themed wrapper and theme CSS token wiring.
- Browser: axe on registered examples; live example with
announce="alert"after interaction; action focus inactionsslot. - Visual baselines for registered examples via
pnpm test:visual:docker.
Documentation plan
docs/components/inline-alert.md with API reference, static vs live announce guidance, DataTable failure patterns, themed props, accessibility notes, and registered examples. Playground section mirroring headless and themed cases.
Compatibility and release impact
Additive; minor Changesets for @ghostvue/vue and @ghostvue/themes.
Open architectural questions
None blocking. GHO-38 remains undecided; this reuses existing data-part and class hooks.
Status tone amendment
Important
Approved on 2026-12-02 by zprue743. This amendment adds success and warning to the themed tone. It reuses the Badge status-tone mapping and adds no tokens. The maintainer zprue743 chose this tone set on 2026-12-01 and approved the amendment text on 2026-12-02. It is implemented in @ghostvue/themes, and the themed props table above includes both tones.
Why status tones
An inline alert that reports a healthy or degraded state has no tone for it. accent follows the brand color, so a "healthy" alert turns purple in Vibrant and is close to neutral in Mono. neutral reads as inactive, so a "degraded" alert looks like ordinary copy. GhostBadge already takes success and warning for the same reason; an alert next to a badge should be able to use the same tone.
Proposed public API
Themed GhostInlineAlert in @ghostvue/themes only:
| Prop | Type | Default | Contract |
|---|---|---|---|
tone | 'accent' | 'neutral' | 'danger' | 'success' | 'warning' | 'neutral' | Semantic color intent, independent of variant. Not a status enum. |
GhostInlineAlertTonegainssuccessandwarning. The default staysneutraland still omitsdata-tone; the new tones renderdata-tone="success"anddata-tone="warning".infois not added. Informational copy keepsneutral, as onGhostBadge.tonestays a color intent. The title and message carry the meaning, andannouncestill decides live-region semantics;tonenever sets arole.- Headless
@ghostvue/vuedoes not change: no prop, type, or manifest change.
Token mapping
accent, neutral, and danger keep their action-tone colors. success and warning read the existing status tokens, exactly as GhostBadge does, with no new tokens and no per-component tokens. Text applies to the root, the title, and the message:
| Variant | Text | Fill | Border |
|---|---|---|---|
soft | --ghost-status-<tone>-fg | --ghost-status-<tone>-bg | --ghost-status-<tone>-border |
outline | --ghost-status-<tone>-fg | transparent | --ghost-status-<tone>-fg |
ghost | --ghost-status-<tone>-fg | transparent | transparent |
solid | --ghost-status-<tone>-bg | --ghost-status-<tone>-fg | --ghost-status-<tone>-fg |
<tone> is success or warning.
- Title and message. Both use the text color in the table. The
neutralsoft alert's muted message color is not used for status tones, because the required contrast pair isstatus.<tone>.fgonstatus.<tone>.bg. - Solid.
solidswaps thefgandbgpair, so it keeps the same ratio. There is no gradient fill: themes define gradients only for action tones. - Actions. Transparent action controls in
#actions(outlineandghostGhostButton) take the alert's text color in every variant. Today the recipe rule that does this matches onlydata-tone="danger". The implementation must extend it tosuccessandwarning. Without it, those buttons keep their default accent color, which can fall far below 3:1 on a solid status fill. Filled action buttons keep their own tone. - Forced colors. Unchanged: every tone resolves to
CanvasTextonCanvas.
Accessibility
Roles, names, live-region behavior, keyboard, and focus do not change. Color stays a supplementary encoding: the title and message still say what happened.
Implementation acceptance cases
- Wrapper (unit).
tone="success"andtone="warning"render the matchingdata-tone;neutraland an omittedtonerender none. A type test accepts both new tones and rejectstone="info". - Token wiring (integration). The recipe maps each new tone and variant to the status tokens in the table, reads no action-tone token for them, and turns the solid gradient off.
- Contrast.
pnpm contrastkeeps the--ghost-status-success-*and--ghost-status-warning-*text and fill pairs at WCAG 2 AA in light and dark for all four flagships (default, Calm, Vibrant, Mono). A browser check measures the rendered title and message text of each new tone in every variant, in light and dark, for the same four themes (at least 4.5:1). - Transparent actions. The existing danger-action contrast matrix in
tests/e2e/ghost-inline-alert.spec.tsalso coverssuccessandwarning. For each new tone, every alert variant (solid,soft,outline,ghost),outlineandghostaction buttons, light and dark, and all four flagships, it requires the following. The button label is at least 4.5:1 against the alert fill. The focus ring of the focused button is at least 3:1. Theoutlinebutton border is opaque and at least 3:1. Theghostbutton border stays transparent. A registered example or playground fixture provides one alert per new tone with a transparent action. - Distinct tones in Mono. In Mono, light and dark, a browser check renders
neutral,success,warning, anddangersoft alerts side by side and asserts that adjacent tones resolve to different text colors and fills. - Defaults unchanged. Existing tones, the
neutraldefault, and the registered examples render as before. - Manifests and API tables.
pnpm manifests:writerecords the tones inpackages/themes/manifests/ghost-inline-alert.manifest.json, andpnpm docs:api:writeupdates the generated API table.
Documentation plan
docs/components/inline-alert.mdexplains which tone to pick (successfor healthy or completed,warningfor degraded or needs attention soon,dangerfor failures) and thataccentdoes not mean success.- One runnable example shows the status tones side by side.
- A
@ghostvue/themesChangeset.
Compatibility
Additive for @ghostvue/themes (minor Changeset). Existing tones, the neutral default, and omitted-attribute behavior are unchanged, and @ghostvue/vue is untouched. Removing a tone, or adding a tone not listed here, requires compatibility review.