Skip to content

Commit 7b7b461

Browse files
authored
feat(Button): add support for aria-current prop (#7643)
1 parent 9bb6ed9 commit 7b7b461

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

packages/@react-aria/button/src/useButton.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export function useButton(props: AriaButtonOptions<ElementType>, ref: RefObject<
107107
'aria-expanded': props['aria-expanded'],
108108
'aria-controls': props['aria-controls'],
109109
'aria-pressed': props['aria-pressed'],
110+
'aria-current': props['aria-current'],
110111
onClick: (e) => {
111112
if (deprecatedOnClick) {
112113
deprecatedOnClick(e);

packages/@react-types/button/src/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ interface AriaBaseButtonProps extends FocusableDOMProps, AriaLabelingProps {
5555
'aria-controls'?: string,
5656
/** Indicates the current "pressed" state of toggle buttons. */
5757
'aria-pressed'?: boolean | 'true' | 'false' | 'mixed',
58+
/** Indicates whether this element represents the current item within a container or set of related elements. */
59+
'aria-current'?: boolean | 'true' | 'false' | 'page' | 'step' | 'location' | 'date' | 'time',
5860
/**
5961
* The behavior of the button when used in an HTML form.
6062
* @default 'button'

packages/react-aria-components/test/Button.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ describe('Button', () => {
5151
expect(button).toHaveAttribute('formMethod', 'post');
5252
});
5353

54+
it('should support accessibility props', () => {
55+
let {getByRole} = render(<Button aria-current="page">Test</Button>);
56+
let button = getByRole('button');
57+
expect(button).toHaveAttribute('aria-current', 'page');
58+
});
59+
5460
it('should support slot', () => {
5561
let {getByRole} = render(
5662
<ButtonContext.Provider value={{slots: {test: {'aria-label': 'test'}}}}>

0 commit comments

Comments
 (0)