React fix

Before and after

Broken — before
// Broken React icon link: SVG child with no discernible text
import { ExternalLink } from "lucide-react";

export function DocsIconLink({ href }: { href: string }) {
  return (
    <a href={href} className="icon-link">
      <ExternalLink size={16} />
    </a>
  );
}
Fixed — after
// Fixed React IconLink: required label prop + decorative SVG hidden from AT
import type { AnchorHTMLAttributes, ReactNode } from "react";
import { ExternalLink } from "lucide-react";

interface IconLinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
  href: string;
  label: string;
  icon: ReactNode;
}

export function IconLink({ href, label, icon, ...props }: IconLinkProps) {
  return (
    <a href={href} aria-label={label} {...props}>
      <span aria-hidden="true">{icon}</span>
    </a>
  );
}

export function DocsIconLink({ href, title }: { href: string; title: string }) {
  return <IconLink href={href} label={`Read ${title} documentation`} icon={<ExternalLink size={16} />} />;
}
Live preview

Fixed vs. broken example

Passes link-name
Accessibility tree: role="link", accessible name="View A11yDrift on GitHub" (SVG marked aria-hidden="true")

Open the VoiceOver Web Rotor (Control+Option+U) or NVDA Elements List (NVDA+F7) to confirm every icon anchor shows a clear destination label.

Automated test

Playwright + axe-core check

tests/a11y-link-name.spec.ts
import { test, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";

test("React navigation and icon anchors pass axe-core link-name", async ({ page }) => {
  await page.goto("/integrations");
  const results = await new AxeBuilder({ page })
    .withRules(["link-name"])
    .analyze();
  expect(results.violations).toEqual([]);
});

Template deduplication tip

An unnamed table-row external link or footer icon component repeated across 50 React views collapses in A11yDrift to one normalized component selector—edit one TSX component to resolve every route.

Screen readers

What NVDA and VoiceOver announce

Screen-reader users routinely pull up a rotor or links list to jump straight to destinations. Bare icon anchors, empty product-image wrappers, or unlabeled social links appear as meaningless raw URLs or blank entries.

NVDA (Windows)

Broken

"link, #social-demo" (raw href fragment read verbatim)


Fixed

"View A11yDrift on GitHub, link"

VoiceOver (macOS / iOS)

Broken

"link" (or raw URL path)


Fixed

"View A11yDrift on GitHub, link"

Common questions

Why did my React <a href> fail link-name when it contains an <img>?
If the only child inside an <a> is an <img> with alt="" (empty) or missing alt, the link's computed accessible name is empty. Either give the image descriptive destination alt text or set aria-label on the <a>.
When should I use <a> vs <button> in React?
Use <a href='...'> for URL navigation and <button type='button'> for in-page actions (opening modals, submitting filters, toggling drawers). Never strip href from an <a> to fake a button.
Are generic labels like 'Click here' or 'Read more' flagged by link-name?
axe-core link-name checks whether discernible text exists, so 'Read more' passes the automated presence check—but still hurts WCAG 2.4.4 usability. Prefer specific names like 'Read WCAG 2.2 checklist guide'.