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
VisuallyHidden is positioned absolutely, so it needs a positioned ancestor. Otherwise, it will be positioned relative to the nearest positioned ancestor, which may be the body, causing undesired scroll bars to appear.
35
24
36
-
See [useRadioGroup](useRadioGroup.html#styling) and [useCheckbox](useCheckbox.html#styling)
37
-
for examples of using `VisuallyHidden` to hide native form elements visually. */}
25
+
```tsx
26
+
<labelstyle={{position: 'relative'}}>
27
+
<VisuallyHidden>
28
+
<inputtype="checkbox" />
29
+
</VisuallyHidden>
30
+
<span>Subscribe to our newsletter</span>
31
+
</label>
32
+
```
38
33
39
-
## Hook
34
+
## Hook
40
35
41
36
In order to allow additional rendering flexibility, the `useVisuallyHidden` hook can be
42
37
used in custom components instead of the `VisuallyHidden` component. It supports the same
43
38
options as the component, and returns props to spread onto the element that should be hidden.
@@ -52,16 +49,12 @@ let {visuallyHiddenProps} = useVisuallyHidden();
52
49
<div{...visuallyHiddenProps}>I am hidden</div>
53
50
```
54
51
55
-
## Gotchas
52
+
## API
56
53
57
-
VisuallyHidden is positioned absolutely, so it needs a positioned ancestor. Otherwise, it will be positioned relative to the nearest positioned ancestor, which may be the body, causing undesired scroll bars to appear.
0 commit comments