link

Alink

Accessible link styled as a component.

Alink Examples

Copy-ready examples with live previews.

Basic usage

Thin wrapper around the native <a> element.

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.

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.

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.

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.

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>
  );
}

On this page

Alink Props

Alink — Props
PropTypeRequiredDefaultDescription
hrefstringNoundefinedLink destination. Omitted when ariaDisabled=true.
target"_self" | "_blank" | "_parent" | "_top" | stringNoundefinedStandard anchor target.
relstringNoundefinedStandard rel attribute. If target="_blank" and rel is missing, it defaults to "noopener noreferrer".
downloadboolean | stringNoundefinedEnables download behavior (boolean) or provides a filename (string).
hrefLangstringNoundefinedLanguage of the linked URL (BCP 47).
typestringNoundefinedMIME type of the linked content.
referrerPolicystringNoundefinedControls the Referer header behavior for the request.
pingstringNoundefinedSpace-separated list of URLs to ping when the link is followed.
mediastringNoundefinedMedia query hint for linked content.
idstringNoundefinedGlobal id.
classNamestringNoundefinedCSS class(es).
styleReact.CSSPropertiesNoundefinedInline style object.
titlestringNoundefinedNative text tooltip.
tabIndexnumberNoundefinedFocus order. Forced to -1 when ariaDisabled=true.
rolestringNoundefinedOptional ARIA role.
ariaLabelstringNoundefinedMaps to aria-label (useful for icon-only links).
ariaCurrent"page" | "step" | "location" | "date" | "time" | "true" | "false"NoundefinedMaps to aria-current (useful for active navigation states).
ariaDisabledbooleanNofalseDisables navigation and clicks, omits href, sets aria-disabled, and makes the link unfocusable.
onClick(e: React.MouseEvent<HTMLAnchorElement>) => voidNoundefinedClick handler (not fired when ariaDisabled=true).
childrenReact.ReactNodeYesLink contents.