Skip to content

Commit

Permalink
add support for label props for carousel arrows for accessibility pur…
Browse files Browse the repository at this point in the history
…poses (#174)
  • Loading branch information
NRohrer authored Apr 1, 2021
1 parent 0793f33 commit 4d6d769
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/carousel/CarouselArrows.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export default function CarouselArrows({
count,
setSelected,
infinite,
leftArrowLabel,
rightArrowLabel,
}) {
classes = useStyles({ classes })

Expand All @@ -70,6 +72,7 @@ export default function CarouselArrows({
<IconButton
className={clsx(classes.arrow, classes.leftArrow)}
onClick={createOnClickArrow(-1)}
aria-label={leftArrowLabel}
>
<ChevronLeft classes={{ root: classes.icon }} />
</IconButton>
Expand All @@ -78,6 +81,7 @@ export default function CarouselArrows({
<IconButton
className={clsx(classes.arrow, classes.rightArrow)}
onClick={createOnClickArrow(1)}
aria-label={rightArrowLabel}
>
<ChevronRight classes={{ root: classes.icon }} />
</IconButton>
Expand Down Expand Up @@ -111,6 +115,19 @@ CarouselArrows.propTypes = {
* Total number of slides in the [`Carousel`](/apiReference/carousel/Carousel).
*/
count: PropTypes.number,

/**
* Label given to the left arrow for accessbility purposes.
*/
leftArrowLabel: PropTypes.string,

/**
* Label given to the right arrow for accessbility purposes.
*/
rightArrowLabel: PropTypes.string,
}

CarouselArrows.defaultProps = {}
CarouselArrows.defaultProps = {
leftArrowLabel: 'Previous',
rightArrowLabel: 'Next',
}

0 comments on commit 4d6d769

Please sign in to comment.