Link
A hyperlink. Detects external URLs and sets the right rel and target
without being told.
import { Link } from "antlitz";
In a Next.js app, import from antlitz/next instead — same props, rendered
through next/link so client-side navigation works.
import { Link } from "antlitz/next";
API
| Prop | Type | Default |
|---|---|---|
| as | ElementType | — |
| asChild | boolean | false |
| href | string | # |
| refValue | string | — |
| variant | "default" | "plain" | default |
Variants
export function Variants() {
return (
<>
<Link href="/components/button">Internal link</Link>
<Link href="https://example.com">External link</Link>
<Link href="https://example.com" variant="plain">
Plain link
</Link>
</>
);
}External links get target="_blank" and rel="noopener noreferrer"
automatically. Internal ones do not, so in-app navigation is never hijacked
into a new tab.
An external link also says "(opens in new tab)" to screen readers. The ↗
beside it is drawn with empty CSS alt text, so the warning is heard once,
without "north east arrow" after it.
Through antlitz/next, every same-origin href renders through next/link —
a path, a query string such as ?page=2, a relative link. Hash-only links and
other schemes such as mailto: stay plain anchors, since there is nothing for
the router to do.
variant="plain" removes the underline and colour, for links already styled by
what they wrap — a card, a logo, a nav item.
Referrer
export function Referrer() {
return (
<Link href="https://example.com" refValue="antlitz.vercel.app">
External link with a referrer parameter
</Link>
);
}refValue appends a referrer parameter to external URLs — useful when linking
out to your own properties and you want the traffic attributed.
Composition
export function Composition() {
return (
<Button asChild variant="outline">
<Link href="https://example.com" variant="plain">
Styled as a button
</Link>
</Button>
);
}asChild lets another component provide the styling while Link keeps the
anchor semantics and external-URL handling.