Rated 4 out of 5
Context for a screen reader
import { Text, VisuallyHidden } from "@senvenli/react/display";
export default function Example() {
return (
<Text>
<span aria-hidden>★★★★☆</span>
<VisuallyHidden>Rated 4 out of 5</VisuallyHidden>
</Text>
);
}import { VisuallyHidden } from "@senvenli/react/display";Guidelines
When to use it
- A heading that names a region the layout already makes obvious.
- Context an icon or a glyph gives sighted users.
Use something else when
- A link to jump past the navigation. Skip link
Do and avoid
- Never hide something a sighted user needs to read.
Accessibility
Built in
- Hidden with the sr-only technique, so it stays in the accessibility tree.
isFocusable: shown while it has keyboard focus.
You provide
- The words to read.
API reference
VisuallyHidden
| Prop | Type | Default | Description |
|---|---|---|---|
childrenRequired | React.ReactNode | – | |
elementType | "div" | "span" | "label" | "h2" | "h3" | "span" |
|
isFocusable | boolean | – | Shown while it, or something in it, has keyboard focus: a skip link, a hidden "edit" action. |
id | string | – |
childrenRequiredReact.ReactNodeelementType"div" | "span" | "label" | "h2" | "h3"Default"span"span(default) inside a line,divfor a block (a hidden heading that names a region).isFocusablebooleanShown while it, or something in it, has keyboard focus: a skip link, a hidden "edit" action.
idstring