Skip to content

Commit 9ee4f0e

Browse files
Prop to add aria-labelledby attribute for accessibility
1 parent 12211bd commit 9ee4f0e

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ Type: `func`
8787
<Tour badgeContent={(curr, tot) => `${curr} of ${tot}`} />
8888
```
8989

90+
#### ariaLabelledBy
91+
92+
> `ariaLabelledBy` attribute to associate the dialog with a title for screen readers (accessibility)
93+
94+
Type: `string`
95+
9096
#### children
9197

9298
> Content to be rendered inside the _Helper_

src/Tour.js

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ function Tour({
5252
maskSpace,
5353
showCloseButton,
5454
closeButtonAriaLabel,
55+
ariaLabelledBy,
5556
}) {
5657
const [current, setCurrent] = useState(0)
5758
const [started, setStarted] = useState(false)
@@ -310,6 +311,7 @@ function Tour({
310311
[CN.helper.isOpen]: isOpen,
311312
})}
312313
role="dialog"
314+
aria-labelledby={ariaLabelledBy}
313315
>
314316
{CustomHelper ? (
315317
<CustomHelper

src/propTypes.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import PropTypes from 'prop-types'
22

33
export const propTypes = {
4+
ariaLabelledBy: PropTypes.string,
45
badgeContent: PropTypes.func,
56
highlightedMaskClassName: PropTypes.string,
67
children: PropTypes.oneOfType([PropTypes.node, PropTypes.element]),

0 commit comments

Comments
 (0)