Skip to content

Commit a888cd8

Browse files
savcni01eps1lon
andauthored
feat(byRole): add documentation for new option (aria-current) of ByRole queries (#822)
Co-authored-by: eps1lon <silbermann.sebastian@gmail.com>
1 parent c016d1a commit a888cd8

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

docs/queries/byrole.mdx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ getByRole(
2424
selected?: boolean,
2525
checked?: boolean,
2626
pressed?: boolean,
27+
current?: boolean | string,
2728
expanded?: boolean,
2829
queryFallbacks?: boolean,
2930
level?: number,
@@ -142,6 +143,27 @@ state and which elements can have this state see
142143
> Checkboxes have a "mixed" state, which is considered neither checked nor
143144
> unchecked (details [here](https://www.w3.org/TR/html-aam-1.0/#details-id-56)).
144145
146+
### `current`
147+
148+
You can filter the returned elements by their current state by setting
149+
`current: boolean | string`.
150+
Note that no `aria-current` attribute will match `current: false` since `false` is the default value for `aria-current`.
151+
152+
For example in
153+
154+
```html
155+
<body>
156+
<nav>
157+
<a href="current/page" aria-current="true">👍</a>
158+
<a href="another/page">👎</a>
159+
</nav>
160+
</body>
161+
```
162+
163+
you can get the "👍" link by calling `getByRole('link', { current: true })` and the "👎" by calling `getByRole('link', { current: false })`.
164+
To learn more about the current state see
165+
[ARIA `aria-current`](https://www.w3.org/TR/wai-aria-1.2/#aria-current).
166+
145167
### `pressed`
146168

147169
Buttons can have a pressed state. You can filter the returned elements by their

0 commit comments

Comments
 (0)