Anchor
Link with animated underline and popover preview.
Hover me
import { Anchor } from "ui-lab-components";
export function Example() {
return (
<Anchor>
Click me
<Anchor.Preview>
<div>Preview</div>
</Anchor.Preview>
</Anchor>
);
}Inline Text
Anchor used inline within a paragraph — the primary use case for navigational links.
Read the MDN documentation for a full reference on anchor semantics, or check the WCAG link purpose guidelines for accessibility requirements.
import { Anchor } from 'ui-lab-components';
export const metadata = {
title: 'Inline Text',
description: 'Anchor used inline within a paragraph — the primary use case for navigational links.',
};
export default function Example() {
return (
<p className="text-sm text-foreground max-w-prose leading-relaxed">
Read the{" "}
<Anchor href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a">
MDN documentation
</Anchor>{" "}
for a full reference on anchor semantics, or check the{" "}
<Anchor href="https://www.w3.org/WAI/WCAG21/Understanding/link-purpose-in-context.html">
WCAG link purpose guidelines
</Anchor>{" "}
for accessibility requirements.
</p>
);
}
Underline Variants
Three underline styles available via Anchor.Underline: solid (default), dashed, and dotted.
import { Anchor, Flex } from 'ui-lab-components';
export const metadata = {
title: 'Underline Variants',
description: 'Three underline styles available via Anchor.Underline: solid (default), dashed, and dotted.',
};
export default function Example() {
return (
<Flex gap="lg" align="center">
<Anchor href="#">
Solid
</Anchor>
<Anchor href="#">
<Anchor.Underline variant="dashed" />
Dashed
</Anchor>
<Anchor href="#">
<Anchor.Underline variant="dotted" />
Dotted
</Anchor>
</Flex>
);
}
Preview Tooltip
Hover over the links to see a tooltip preview — composed via the preview prop or Anchor.Preview.
import { Anchor, Flex } from 'ui-lab-components';
export const metadata = {
title: 'Preview Tooltip',
description: 'Hover over the links to see a tooltip preview — composed via the preview prop or Anchor.Preview.',
};
export default function Example() {
return (
<Flex gap="lg" align="center">
<Anchor
href="https://github.com"
preview={
<span className="text-xs text-foreground-400">github.com</span>
}
>
GitHub
</Anchor>
<Anchor href="https://vercel.com">
<Anchor.Preview>
<span className="text-xs text-foreground-400">vercel.com</span>
</Anchor.Preview>
Vercel
</Anchor>
</Flex>
);
}
Breadcrumb
Anchor used as navigational crumbs — the last segment is non-interactive text.
import { Anchor, Flex } from 'ui-lab-components';
export const metadata = {
title: 'Breadcrumb',
description: 'Anchor used as navigational crumbs — the last segment is non-interactive text.',
};
const crumbs = [
{ label: 'Home', href: '/' },
{ label: 'Projects', href: '/projects' },
{ label: 'ui-lab', href: '/projects/ui-lab' },
];
export default function Example() {
return (
<Flex gap="xs" align="center" className="text-sm">
{crumbs.map((crumb, i) => (
<span key={crumb.href} className="flex items-center gap-xs">
{i > 0 && <span className="text-foreground-400 mx-1">/</span>}
{i < crumbs.length - 1 ? (
<Anchor href={crumb.href}>{crumb.label}</Anchor>
) : (
<span className="text-foreground-400">{crumb.label}</span>
)}
</span>
))}
</Flex>
);
}