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
These colors are made for the page. On a filled surface, a filled announcement banner, a CTA or hero on the accent, or a section on the accent or the inverse background, every variant takes the surface's own text color instead, and the underline is what marks the link there.
Under the pointer, a default or text link fades a little, to --opacity-wk-hover. A muted or
subtle link takes the color of the running text instead: its gray sits close to the 4.5:1 that
text needs, and a fade would take it below. In every bundled theme preset, light and dark, a link
keeps at least 4.5:1 while hovered, on the page and on its subtle and elevated surfaces.
External Links
With external, a link gets target="_blank", rel="noopener noreferrer", and a small arrow icon. The component does not decide from the address whether a link leaves the site: set external where it does.
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
underline="quiet" keeps the line but draws it in the border color, lighter than the words, which suits a screen with many links on it, such as the names in a list or a back link above a page. Under the pointer and on focus the line takes the color of the link. The words still read as a link without their color, since the line stays.
A Link in the Color of the Text
variant="text" draws the link in the color of the running text and keeps its underline. Inside a sentence, the underline is what tells a reader that the words are a link, so leave it on there: without it, the link looks like the text around it (WCAG 1.4.1).
Where the link stands on its own, such as the number of an order in a column of a table, the column already says what the numbers are. There underline="hover" shows the underline only under the pointer, and the focus ring still shows where the keyboard is.
To draw every link that names no variant in the color of the text, set it once as the default, see Customization.
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="#".
Words that are a link only for some readers
A page often names something that has a page of its own: the order of a return, a customer, a rule. For a reader who may open that page, the words are a link. For a reader who may not, the page would answer "not found", so the words should be plain text.
A link without an href renders an <a> without one, which looks like a link and is none: it takes no focus, and a click does nothing. With plain-without-href, a link without an href draws its words as text instead, a <span> without the link's color, underline, pointer and focus ring:
Return for order #1042, placed by Jane Cooper.
Give the link its href only for a reader who may follow it:
<x-wirekit::link
:href="Gate::allows('view', $order) ? route('orders.show', $order) : null"
plain-without-href
>{{ $order->number }}</x-wirekit::link>
With an href, the prop changes nothing. The words keep size, and every attribute you give them, such as an id, a data-* attribute or a wire:key. What only a link reads stays with the link: target, rel, download, hreflang, ping, referrerpolicy and type, wire:navigate and wire:current, and an aria-label or aria-labelledby unless you give the words a role. as="button" keeps its button, since a button never has an href.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
href |
string|null | null |
Link URL |
variant |
string | 'default' |
Color: default, subtle, muted, text. text is the color of the running text, see A Link in the Color of the Text |
size |
string|null | null |
Font size: xs, sm, base, lg, xl — the same rung names text uses, so one vocabulary covers both. null takes the size and the font family of the surrounding copy, which is what a link inside a sentence wants, in a monospaced or a serif sentence too. Name a size when the link stands on its own, as in a footer or a preferences row, and it sets the kit's sans family with it |
external |
bool | false |
Opens in a new tab with rel="noopener noreferrer" and the 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 |
plain-without-href |
bool | false |
Without an href, draws the words as text, a <span> without the link's look. With an href, it changes nothing, see Words that are a link only for some readers |
underline |
string | 'always' |
Underline behavior: always, hover, none, quiet (a line in the border color that takes the link's color under the pointer and on focus) |
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 show that they open in a new tab, 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.
An <a> without an href is not a link to a keyboard or a screen reader: it takes no focus and has no role. With plain-without-href it is text, and it no longer looks like a link either.
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 addsrel="noopener noreferrer"for_blankitself, which keeps the opened page from reaching the one that opened it. Arelof your own is kept and the two are added to it, so writing them is only redundant. - Don't wrap a whole card in
<x-wirekit::. The link colors and underlines every word inside it, as it does for words in a sentence. A card that leads somewhere takes the card's ownlink> href, see Clickable Card.
Design Tokens
| Token | Used for |
|---|---|
--font-wk-sans |
Font family, when size names a rung. Unset, the link takes the family of the text around it |
--color-wk-accent-text |
default variant link color |
--color-wk-text-subtle |
subtle variant link color |
--color-wk-text-muted |
muted variant link color |
--color-wk-text |
text variant link color, and the color of a muted or subtle link under the pointer |
--opacity-wk-hover |
How far a default or text link fades under the pointer |
--color-wk-border |
The line of underline="quiet", until the pointer or the focus reaches the link |
--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 |
Customization
A link that names no variant or underline takes both from the components array of config/. One line changes every such link, the links a package draws in its own views included:
// config/wirekit.php
'components' => [
'link' => ['variant' => 'text', 'underline' => 'always'],
],
WireKit:: in a service provider does the same without publishing the config, see PHP Defaults. A link that names its own variant or underline keeps it.
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.