Controls and surfaces
accessible-icon
Gives an icon that stands alone a name for screen readers, and hides the drawing itself from them.
When to use it
An icon that carries meaning with no words beside it and is not itself a control: a status mark in a table cell, a warning beside a figure. An icon-only button or link takes aria-label on the control instead; an icon beside its own words is decoration and takes aria-hidden.
See it working
The demonstration the browser checks drive, with the keyboard as well as the pointer. More of it is on the Primitives page.
Alert dialog
The project is kept.
Collapsible
The options are closed.
Hover card
The first published program was written by Ada Lovelace.
Menubar
Command: none yet. Ruler: hidden. Zoom: 100.
Navigation menu
Toolbar
Styles: none. Saved 0 times.
One-time code
Typed: nothing yet. Sent: nothing yet.
Password
Words for screen readers
Rosalind Franklin
Add it
npx shadcn@latest add @rivier-ui/accessible-iconThe registry is named once in components.json: see Installation.
Example
Import it from @/components/ui/accessible-icon.
<AccessibleIcon label="Verified"><BadgeCheck strokeWidth={1.5} className="size-4" /></AccessibleIcon>What it needs
Plain markup: it can stay a server component. Packages: radix-ui.
Source
The whole file. Once copied it is yours: the registry item holds the same text.
/**
* @name accessible-icon
* @category ui
* @description Gives an icon that stands alone a name for screen readers, and hides the drawing itself from them.
* @when An icon that carries meaning with no words beside it and is not itself a control: a status mark in a table cell, a warning beside a figure. An icon-only button or link takes `aria-label` on the control instead; an icon beside its own words is decoration and takes `aria-hidden`.
* @example
* <AccessibleIcon label="Verified"><BadgeCheck strokeWidth={1.5} className="size-4" /></AccessibleIcon>
*/
import { AccessibleIcon as AccessibleIconPrimitive } from "radix-ui";
import type { ComponentProps } from "react";
/** `label` is what is read out. The one child is the icon. */
export function AccessibleIcon(props: ComponentProps<typeof AccessibleIconPrimitive.Root>) {
return <AccessibleIconPrimitive.Root {...props} />;
}