Skip to content
Likable Aurora @likable-hair/svelte 5

LinkButton

Text link with an animated underline: a short gradient stroke that grows to the full width on hover and focus, while the icon after the text slides forward. It renders a native <a>: href, target, download and events (onclick, ...) work as in HTML, and with target="_blank" rel defaults to noopener noreferrer. A disabled link loses its href and gets aria-disabled, so it cannot be followed or focused and does not call onclick. For a link that looks like a button use Button with href. Its state is exposed as data-disabled for app CSS.

import { LinkButton } from '@likable-hair/svelte';

src/lib/components/simple/buttons/LinkButton.svelte · Markdown for LLMs

Basic

A text link whose underline grows on hover and focus. appendIcon slides forward with it; prependIcon stays still. The color comes from --link-button-color.

Code
<script lang="ts">
	import { mdiArrowRight, mdiBookOpenVariant } from '@mdi/js';
	import { LinkButton } from '@likable-hair/svelte';
</script>

<div class="row">
	<LinkButton href="#appointments" appendIcon={mdiArrowRight}>See all appointments</LinkButton>
	<LinkButton
		href="https://svelte.dev"
		target="_blank"
		prependIcon={mdiBookOpenVariant}
		--link-button-color="var(--global-color-primary)"
	>
		Documentation
	</LinkButton>
	<LinkButton href="#disabled" disabled>Disabled</LinkButton>
</div>

<style>
	.row {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		gap: 12px 28px;
	}
</style>

Inside text

The link is inline: it takes the font size of the text around it, so it can sit inside a sentence.

Your plan renews on 1 November. You can change the payment method or cancel the renewal at any time.

Code
<script lang="ts">
	import { LinkButton } from '@likable-hair/svelte';
</script>

<p>
	Your plan renews on 1 November. You can <LinkButton href="#billing">change the payment method</LinkButton>
	or <LinkButton href="#cancel">cancel the renewal</LinkButton> at any time.
</p>

<style>
	p {
		max-width: 46ch;
		margin: 0;
		line-height: 1.7;
	}
</style>

Props

NameTypeDefaultDescription
href requiredstringURL of the link.
target '_self' | '_blank' | '_parent' | '_top' | (string & {})Native target. With _blank, rel defaults to noopener noreferrer.
rel stringNative rel.
disabled booleanfalseRemoves the href and sets aria-disabled: the link cannot be followed, focused or clicked.
prependIcon stringSVG path of an icon before the text, for example from @mdi/js.
appendIcon stringSVG path of an icon after the text. It slides forward on hover.
linkElement bindable HTMLAnchorElementThe native <a> element.

It also accepts the native attributes and events of <a> (for example id, title, aria-label, onkeydown), which are forwarded to the element.

Snippets

NameParametersDescription
childrenLink text.
prependSnippet{ prependIcon: string | undefined }Replaces the icon before the text.
appendSnippet{ appendIcon: string | undefined }Replaces the icon after the text. It still slides forward on hover.

CSS variables

For a single instance, pass them as style props: <LinkButton --link-button-background="tomato">. The --link-button-default-* defaults apply to the whole app: override them in :root or in a theme.

Per-instance variableDefault