Link
A styled anchor element with variants, underline control, and external link support.
Live Sandbox
This is a hydrated playground for the component. Toggle "Live preview" on the block below to swap the static HTML render for a real Livewire instance — every prop in the component's sandbox schema becomes an editable form field inside the iframe, so you can try different prop combinations live without writing any local code.
Basic Usage
Variants
External Links
External links automatically get target="_blank", rel="noopener noreferrer", and a small arrow icon.
When script turns the link into something else
A link that opens a new tab says so twice: external draws the arrow icon, and every target="_blank" carries a screen-reader hint, "(opens in new tab)". Some anchors only open a tab when script is off. A document link in a sign-up form can open the document in a dialog when script runs and in a new tab when it does not, so the form keeps what the reader typed either way. There the automatic hint is wrong whenever the dialog opens.
:announce-new-tab="false" drops the icon and the hint and keeps target and the forced rel="noopener noreferrer":
I have read the privacy policy.
The call site then says what the reader gets. A hint that script removes is announced only when the new tab is what happens:
<x-wirekit::link
href="{{ route('legal.privacy') }}"
target="_blank"
:announce-new-tab="false"
x-on:click.prevent="$dispatch('wirekit-modal-show', { name: 'privacy' })"
x-bind:aria-haspopup="'dialog'"
>privacy policy<span class="sr-only" x-show="false"> {{ __('wirekit::(opens in new tab)') }}</span></x-wirekit::link>
The anchor sits inside an Alpine component, which the click handler needs anyway. With script, x-show hides the hint and the bound aria-haspopup announces the dialog; without script, the hint stays and the link opens its tab.
Underline Styles
In Context
Read the getting started guide to learn how to install WireKit in your project.
Link styled as a button
Use as="button" for an action that should look like a link but be a real <button> — accessible and keyboard-operable, without a fake href="#".
Props
| Prop | Type | Default | Description |
|---|---|---|---|
href |
string|null | null |
Link URL |
variant |
string | 'default' |
Color: default, subtle, muted |
size |
string|null | null |
Font size: xs, sm, base, lg, xl — the same rung names text uses, so one vocabulary covers both. null inherits from the surrounding copy, which is what a link inside a sentence wants; name a size when the link stands on its own, as in a footer or a preferences row |
external |
bool | false |
Opens in new tab with rel="noopener noreferrer" and external icon |
announce-new-tab |
bool | true |
Whether a link that opens a new tab says so: the external icon and the screen-reader hint "(opens in new tab)". false drops both and keeps target and the forced rel, see When script turns the link into something else |
underline |
string | 'always' |
Underline behavior: always, hover, none |
as |
string | 'a' |
HTML element to render |
scope |
string|null | null |
Scoped personalization name |
Accessibility
External links include an inline SVG icon with aria-hidden="true" to indicate they open in a new window, and any link with target="_blank" carries the screen-reader hint "(opens in new tab)". The rel="noopener noreferrer" attribute prevents the opened page from accessing the original window; it is forced even with :announce-new-tab="false", which only drops the icon and the hint.
Keyboard Interaction
| Key | Action |
|---|---|
Tab |
Move focus to the link |
Enter |
Activate the link (follow the URL) |
Pitfalls
- Don't add
rel="noopener"manually ontarget="_blank"links. WireKit auto-injectsrel="noopener noreferrer"for_blank(CVE-class tabnabbing fix). Manualrelvalues are merged correctly, but it's redundant. - Don't use
<x-wirekit::for purely decorative anchors. It draws the kit's focus ring and adds a screen-reader hint forlink> _blanktargets, overhead for invisible navigation. A plain<a>is fine for those.
Design Tokens
| Token | Used for |
|---|---|
--font-wk-sans |
Link font family |
--color-wk-accent-text |
default variant link color |
--color-wk-text-subtle |
subtle variant link color |
--color-wk-text-muted |
muted variant link color |
--text-wk-xs … --text-wk-xl |
Font size, when size names a rung. Unset, the link inherits and reads none of these |
--transition-wk-duration / --transition-wk-easing |
Hover transition |
Usage & Conventions
Prop conventions — this component uses one or more of the shared semantic prop names (
intent/variant/tone/surface). See Prop naming conventions for the canonical vocabulary, alias matrix, and decision tree.