Skip to content

Commit 4d6d769

Browse files
authored
add support for label props for carousel arrows for accessibility purposes (#174)
1 parent 0793f33 commit 4d6d769

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/carousel/CarouselArrows.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ export default function CarouselArrows({
5353
count,
5454
setSelected,
5555
infinite,
56+
leftArrowLabel,
57+
rightArrowLabel,
5658
}) {
5759
classes = useStyles({ classes })
5860

@@ -70,6 +72,7 @@ export default function CarouselArrows({
7072
<IconButton
7173
className={clsx(classes.arrow, classes.leftArrow)}
7274
onClick={createOnClickArrow(-1)}
75+
aria-label={leftArrowLabel}
7376
>
7477
<ChevronLeft classes={{ root: classes.icon }} />
7578
</IconButton>
@@ -78,6 +81,7 @@ export default function CarouselArrows({
7881
<IconButton
7982
className={clsx(classes.arrow, classes.rightArrow)}
8083
onClick={createOnClickArrow(1)}
84+
aria-label={rightArrowLabel}
8185
>
8286
<ChevronRight classes={{ root: classes.icon }} />
8387
</IconButton>
@@ -111,6 +115,19 @@ CarouselArrows.propTypes = {
111115
* Total number of slides in the [`Carousel`](/apiReference/carousel/Carousel).
112116
*/
113117
count: PropTypes.number,
118+
119+
/**
120+
* Label given to the left arrow for accessbility purposes.
121+
*/
122+
leftArrowLabel: PropTypes.string,
123+
124+
/**
125+
* Label given to the right arrow for accessbility purposes.
126+
*/
127+
rightArrowLabel: PropTypes.string,
114128
}
115129

116-
CarouselArrows.defaultProps = {}
130+
CarouselArrows.defaultProps = {
131+
leftArrowLabel: 'Previous',
132+
rightArrowLabel: 'Next',
133+
}

0 commit comments

Comments
 (0)