Link

Alpha

An accessible anchor component with external link handling, underline variants, and automatic security attributes for target='_blank'.

Import

import { Link } from "@compa11y/react";

Usage

Example.tsx
import { Link } from "@compa11y/react";

function Example() {
  return (
    <div style={{ display: "flex", flexDirection: "column", gap: "8px" }}>
      <Link href="/docs">Documentation</Link>
      <Link href="https://github.com" external>GitHub</Link>
      <Link href="/pricing" underline="hover">Pricing</Link>
      <Link href="/old-page" disabled>Deprecated page</Link>
    </div>
  );
}

Features

  • Automatic rel='noopener noreferrer' for external links
  • External indicator with screen reader text '(opens in new tab)'
  • Underline variants: always, hover, focus, never
  • Disabled state with aria-disabled
  • CSS variable customization

Props

Link component props
PropTypeDefaultDescription
href*string-Link destination URL
externalbooleanfalseOpens in new tab with security attributes
underline'always' | 'hover' | 'focus' | 'never''always'Underline behavior
disabledbooleanfalseDisables the link
unstyledbooleanfalseRemoves all default styles
children*ReactNode-Link content

Keyboard Interactions

Accessibility
All keyboard interactions follow WAI-ARIA best practices and work without any additional configuration.
Keyboard shortcuts for Link
KeyAction
EnterActivates the link