GhostLink
GhostLink is a navigation control that preserves native link semantics, adds safe new-tab defaults, and supports router composition through as. Import it from @ghostvue/themes for the default inline, subtle, and button-styled treatments. For the unstyled primitive and the useGhostLink composable, see Advanced: headless composition.
Link to docs and outside resources
Resource card with in-app routes, a new-tab link with rel and hint, a same-tab external link, and a disabled link.
A support card built with GhostLink from @ghostvue/themes mixes the link kinds most apps need:
- In-app routes. "Getting started" and "Theme token reference" are same-tab links to pages on this site. Follow one and the page changes; the browser history and middle-click behave as they do for any
<a href>. - New-tab link. "WAI-ARIA Authoring Practices" sets
target="_blank", so GhostLink addsrel="noopener noreferrer", shows the external icon, and appends a visually hidden "(Opens in new tab)" to its accessible name. - Same-tab external link. "Vue.js documentation" sets
external: it shows the icon but leaves the current tab in charge. - Disabled link. The archived migration guide is
disabled, so it has nohref, leaves the tab order, and announces as unavailable.
Every enabled link shows the shared focus ring when reached with Tab.
External and new-tab links
New-tab safety, indicator, and accessible hint.
target="_blank" adds rel="noopener noreferrer", shows the external icon, and appends newTabLabel for assistive technology. Set external when the destination is outside the app but opens in the same tab. Any rel you pass is merged with the safe values, not replaced.
Disabled links
No href, not focusable, and activation cancelled.
Disabled links drop href on native anchors, use tabindex="-1", expose data-state="disabled", and ignore click and auxclick (middle-click) in the capture phase.
Router composition
Themed link rendered through an app router component passed to as, without importing vue-router.
Pass your framework link component (RouterLink, NuxtLink, …) to as and keep supplying its ordinary props (to or custom equivalents) through fallthrough attributes. The themed styles land on the anchor the router component renders. GhostVue does not bundle or import vue-router; the example defines a small stand-in so it runs on its own.
as is a type parameter, so with vueCompilerOptions.strictTemplates the target's props are checked: <GhostLink :as="RouterLink" to="/settings"> types to, and leaving out a required prop is a compile-time error. An element target keeps that element's attributes. GhostLink sets href only on a native anchor, so it never passes href to a component target, and the type rejects it there; give the component its own prop (to) instead.
Inline and subtle variants
Default inline link visuals from @ghostvue/themes.
Importing the themed component loads the default stylesheet. Visual props exist only on this wrapper:
@ghostvue/themes adds these to the headless GhostLink API, which it forwards:
| Prop | Type | Default | Description |
|---|---|---|---|
appearance | 'link' | 'button' | "link" | Visual presentation mode. Use button for GhostButton-styled navigation links. |
variant | 'inline' | 'subtle' | 'solid' | 'soft' | 'outline' | 'ghost' | "inline" | Visual treatment. Defaults to inline for link appearance and solid for button appearance. |
tone | 'accent' | 'neutral' | 'danger' | "accent" | Color intent. Danger applies when appearance is button. The default omits data-tone. |
size | 'sm' | 'md' | 'lg' | "md" | Control size when appearance is button. The default omits data-size. |
Defaults omit matching data-* hooks so CSS can treat a missing attribute as inline / accent. Focus-visible uses the shared focus-ring tokens.
Button-styled links
Navigation link rendered with the GhostButton visual recipe.
Set appearance="button" when a navigation link should look like a GhostButton (for example hero calls to action). It keeps real <a> semantics, disabled href removal, and target="_blank" safety while accepting variant (solid, soft, outline, ghost), tone (accent, neutral, danger), and size (sm, md, lg).
Accessibility
- Use real link text or
aria-label/aria-labelledby. - Decorative external icons stay
aria-hidden; new-tab intent is carried byGhostVisuallyHiddentext. - Disabled links are not in the tab order and must not retain an
href.
Specification: GhostLink specification.
Advanced: headless composition
For teams that bring their own design system, GhostLink from @ghostvue/vue keeps the same link behavior with no visual styling, and useGhostLink applies it to an anchor you render yourself.
Basic use
Native anchor with headless styling hooks.
Native href, target, and event listeners fall through to the root host. The default as value is a. Style it through the ghost-link class and the data-part and data-state hooks.
Composable
Same contract as GhostLink, applied to a native host.
useGhostLink returns rootProps for a host you already render, including the safe rel, disabled href removal, and aria-disabled.
API
See the generated component references for props, emits, slots, exposed members, styling hooks, CSS variables, and executable examples.
| Prop | Type | Default | Description |
|---|---|---|---|
as | GhostLinkElement | TTarget | "a" | Host element or router component (RouterLink, NuxtLink, …). The type parameter TTarget types a component target's props. |
disabled | boolean | false | Removes href, sets aria-disabled, and cancels activation. |
external | boolean | false | Shows the external icon for same-tab outbound links. |
newTabLabel | string | "Opens in new tab" | Visually hidden hint when target="_blank". |
| Slot | Slot props | Description |
|---|---|---|
default | — | Visible link text. Provide aria-label or aria-labelledby when the slot is empty. |
externalIndicator | — | Decorative external icon inside data-part=external-icon. Hidden from assistive technology. |