Components
Link Button
A text link styled for inline actions, with external-link handling.
Installation
$ npx veil-ui@latest add link-buttonUsage
import { LinkButton } from "@/components/ui/link-button";
<LinkButton href="/docs">Read the docs</LinkButton>;Examples
Basic
By continuing you agree to our terms of service and privacy policy.
External
Variants
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "default" | "muted" | "destructive" | "default" | Colour and weight of the link. |
| underline | boolean | false | Always underline instead of only on hover. |
| external | boolean | false | Adds target, rel and a visually hidden “opens in a new tab” note. |
| asChild | boolean | false | Render your router link instead of an anchor. |
Accessibility
- Renders a real
<a>withhref, so it is reachable with Tab and announced as a link. - External links include the warning in their accessible name, not just an icon.
- Link text describes the destination; avoid “click here”.
Vue and plain HTML
This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add link-button --framework vue or switch the framework in components.json.
<script setup lang="ts">
import { ArrowUpRight } from "lucide-vue-next";
import { Primitive } from "reka-ui";
import { computed, mergeProps } from "vue";
import { cn } from "@/lib/utils";
import { linkButtonVariants, type LinkButtonVariants } from "./variants";
defineOptions({ inheritAttrs: false });
const props = withDefaults(
defineProps<{
variant?: LinkButtonVariants["variant"];
underline?: boolean | null;
asChild?: boolean;
external?: boolean;
class?: string;
}>(),
{
variant: "default",
underline: false,
asChild: false,
external: false,
},
);
const classes = computed(() =>
cn(linkButtonVariants({ variant: props.variant, underline: props.underline }), props.class),
);
const externalProps = computed(() =>
props.external ? { target: "_blank", rel: "noreferrer noopener" } : {},
);
</script>
<template>
<Primitive
v-if="asChild"
as-child
data-slot="link-button"
:class="classes"
v-bind="mergeProps(externalProps, $attrs)"
>
<slot />
</Primitive>
<a
v-else
data-slot="link-button"
:class="classes"
v-bind="mergeProps(externalProps, $attrs)"
>
<slot />
<template v-if="external">
<ArrowUpRight aria-hidden="true" class="size-3.5" />
<span class="sr-only">(opens in a new tab)</span>
</template>
</a>
</template>