You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/rules/a11y-no-visually-hidden-interactive-element.md
+23-1Lines changed: 23 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,23 @@
6
6
7
7
This rule guards against visually hiding interactive elements. If a sighted keyboard user navigates to an interactive element that is visually hidden they might become confused and assume that keyboard focus has been lost.
8
8
9
+
Note: we are not guarding against visually hidden `input` elements at this time. Some visually hidden inputs might cause a false positive (e.g. some file inputs).
10
+
11
+
### Why do we visually hide content?
12
+
13
+
Visually hiding content can be useful when you want to provide information specifically to screen reader users or other assitive technology users while keeping content hidden from sighted users.
14
+
15
+
Applying the following css will visually hide content while still making it accessible to screen reader users.
16
+
17
+
```css
18
+
clip-path: inset(50%);
19
+
height: 1px;
20
+
overflow: hidden;
21
+
position: absolute;
22
+
white-space: nowrap;
23
+
width: 1px;
24
+
```
25
+
9
26
👎 Examples of **incorrect**code for this rule:
10
27
11
28
```jsx
@@ -40,13 +57,18 @@ This rule guards against visually hiding interactive elements. If a sighted keyb
40
57
41
58
## Options
42
59
60
+
- className - A css className that visually hides content. Defaults to `sr-only`.
61
+
- componentName - A react component name that visually hides content. Defaults to `VisuallyHidden`.
62
+
- htmlPropName - A prop name used to replace the semantic element that is rendered. Defaults to `as`.
0 commit comments