Alink
Alink Examples
Copy-ready examples with live previews.
Basic usage
Thin wrapper around the native <a> element.
Live preview
Basic
import Alink from "@/_components/alink/Alink";
export default function Example() {
return (
<>
<Alink href="#docs" onClick={(e) => e.preventDefault()}>Go to docs</Alink>
<Alink href="#pricing" onClick={(e) => e.preventDefault()}>Pricing</Alink>
<Alink href="#account" onClick={(e) => e.preventDefault()} title="Account settings">Account</Alink>
</>
);
}External links (target="_blank")
If target="_blank" and rel is not provided, Alink sets a safe default rel.
Live preview
Auto rel vs custom rel
import Alink from "@/_components/alink/Alink";
export default function Example() {
return (
<>
<Alink href="#external" target="_blank" onClick={(e) => e.preventDefault()}>
External (auto rel)
</Alink>
<Alink href="#external" target="_blank" onClick={(e) => e.preventDefault()} rel="nofollow">
External (custom rel)
</Alink>
</>
);
}Disabled behavior (ariaDisabled)
Blocks navigation/clicks and makes the link unfocusable.
• When ariaDisabled=true, href is omitted and clicks are prevented.
• tabIndex is forced to -1 while disabled.
Live preview
Toggle ariaDisabled
import { useState } from "react";
import Alink from "@/_components/alink/Alink";
import { Button } from "@/_components/buttons_variants/buttons/Button";
export default function Example() {
const [disabled, setDisabled] = useState(true);
return (
<>
<Button variant="primary" onClick={() => setDisabled((v) => !v)}>
Toggle disabled
</Button>
<Alink
href="#billing" onClick={(e) => e.preventDefault()}
ariaDisabled={disabled}
style={{
opacity: disabled ? 0.45 : 1,
cursor: disabled ? "not-allowed" : "pointer",
}}
>
Billing (disabled behavior)
</Alink>
</>
);
}onClick (analytics / custom navigation)
Use onClick for tracking, and optionally prevent default.
• When ariaDisabled=true, onClick is not fired.
Live preview
Track clicks
import { useState } from "react";
import Alink from "@/_components/alink/Alink";
export default function Example() {
const [clicks, setClicks] = useState(0);
return (
<>
<div>Click count: {clicks}</div>
<Alink
href="#docs" onClick={(e) => e.preventDefault()}
onClick={() => setClicks((v) => v + 1)}
>
Track click + navigate
</Alink>
<Alink
href="#docs" onClick={(e) => e.preventDefault()}
onClick={(e) => {
e.preventDefault();
setClicks((v) => v + 1);
// router.push("/docs");
}}
>
Track click + prevent default
</Alink>
</>
);
}Download links
Supports boolean download or filename.
Live preview
download
import Alink from "@/_components/alink/Alink";
export default function Example() {
return (
<>
<Alink href="#brand-assets" download onClick={(e) => e.preventDefault()}>
Download (boolean)
</Alink>
<Alink href="#report" download="report-2026.pdf" onClick={(e) => e.preventDefault()}>
Download (filename)
</Alink>
</>
);
}ARIA helpers
Use ariaCurrent for active routes, and ariaLabel for icon-only links.
Live preview
aria-current + aria-label
import Alink from "@/_components/alink/Alink";
export default function Example() {
return (
<>
<Alink href="#alink" onClick={(e) => e.preventDefault()} ariaCurrent="page">
Current page
</Alink>
<Alink href="#search" onClick={(e) => e.preventDefault()} ariaLabel="Go to search page">
Search
</Alink>
</>
);
}Full attributes example
Forwards common <a> attributes for advanced cases.
Live preview
Full attrs
import Alink from "@/packages/ui/src/_components/alink/Alink";
export default function Example() {
return (
<Alink
href="#external"
target="_blank" onClick={(e) => e.preventDefault()}
hrefLang="en"
type="text/html"
referrerPolicy="no-referrer"
ping="https://example.com/ping"
media="(prefers-color-scheme: dark)"
title="Full attributes example"
>
Full attrs
</Alink>
);
}Next.js Link integration (avoid nested <a>)
If you need Next.js prefetch/routing, render Alink as the child anchor using legacyBehavior.
• Do not nest Alink inside <Link> without legacyBehavior, or you will end up with <a> inside <a>.
Next.js (legacyBehavior + passHref)
import Link from "next/link";
import Alink from "@/packages/ui/src/_components/alink/Alink";
export default function Example() {
return (
<Link href="#docs" onClick={(e) => e.preventDefault()} passHref legacyBehavior>
<Alink>Go to docs</Alink>
</Link>
);
}On this page
Alink Props
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
| href | string | No | undefined | Link destination. Omitted when ariaDisabled=true. |
| target | "_self" | "_blank" | "_parent" | "_top" | string | No | undefined | Standard anchor target. |
| rel | string | No | undefined | Standard rel attribute. If target="_blank" and rel is missing, it defaults to "noopener noreferrer". |
| download | boolean | string | No | undefined | Enables download behavior (boolean) or provides a filename (string). |
| hrefLang | string | No | undefined | Language of the linked URL (BCP 47). |
| type | string | No | undefined | MIME type of the linked content. |
| referrerPolicy | string | No | undefined | Controls the Referer header behavior for the request. |
| ping | string | No | undefined | Space-separated list of URLs to ping when the link is followed. |
| media | string | No | undefined | Media query hint for linked content. |
| id | string | No | undefined | Global id. |
| className | string | No | undefined | CSS class(es). |
| style | React.CSSProperties | No | undefined | Inline style object. |
| title | string | No | undefined | Native text tooltip. |
| tabIndex | number | No | undefined | Focus order. Forced to -1 when ariaDisabled=true. |
| role | string | No | undefined | Optional ARIA role. |
| ariaLabel | string | No | undefined | Maps to aria-label (useful for icon-only links). |
| ariaCurrent | "page" | "step" | "location" | "date" | "time" | "true" | "false" | No | undefined | Maps to aria-current (useful for active navigation states). |
| ariaDisabled | boolean | No | false | Disables navigation and clicks, omits href, sets aria-disabled, and makes the link unfocusable. |
| onClick | (e: React.MouseEvent<HTMLAnchorElement>) => void | No | undefined | Click handler (not fired when ariaDisabled=true). |
| children | React.ReactNode | Yes | — | Link contents. |
Components