Fix link-name in React
React dashboards and marketing sites routinely render icon-only <a href={url}><ExternalLink /></a> or <Link to={path}><img src={logo} alt='' /></Link> elements with zero text content. Enforcing an explicit label prop on an <IconLink> wrapper prevents unnamed anchors from shipping.
Before and after
// 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 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} />} />;
}Fixed vs. broken example
Open the VoiceOver Web Rotor (Control+Option+U) or NVDA Elements List (NVDA+F7) to confirm every icon anchor shows a clear destination label.
Playwright + axe-core check
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.
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)
"link, #social-demo" (raw href fragment read verbatim)
"View A11yDrift on GitHub, link"
VoiceOver (macOS / iOS)
"link" (or raw URL path)
"View A11yDrift on GitHub, link"
Common questions
Why did my React <a href> fail link-name when it contains an <img>?
When should I use <a> vs <button> in React?
Are generic labels like 'Click here' or 'Read more' flagged by link-name?
Test a URL for link-name
Enter any public URL for a free WCAG 2.2 AA check—no account or credit card required.
Shipping React weekly? Block new link-name regressions in PRs with our baseline-diff GitHub Action PR gate (≤20 URLs/PR).