Skip to content

Commit 9ba1a52

Browse files
author
Kubit
committed
Add tabindex and aria props to Checkbox component
1 parent 10e3227 commit 9ba1a52

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

src/components/checkbox/checkboxStandAlone.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ const CheckboxStandAloneComponent = (
139139
screenReaderText,
140140
screenReaderId,
141141
})}
142+
aria-hidden={props['aria-hidden']}
142143
aria-invalid={hasError}
143144
aria-label={props['aria-label']}
144145
aria-labelledby={props['aria-labelledby']}
@@ -149,6 +150,7 @@ const CheckboxStandAloneComponent = (
149150
name={name}
150151
required={required}
151152
styles={styles}
153+
tabIndex={props.tabIndex}
152154
type="checkbox"
153155
value={value}
154156
onBlur={onBlur}

src/components/checkbox/stories/argtypes.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,50 @@ export const argtypes = (variants: IThemeObjectVariants, themeSelected: string):
194194
category: CATEGORY_CONTROL.ACCESIBILITY,
195195
},
196196
},
197+
tabIndex: {
198+
description: 'Tab index',
199+
control: { type: 'number' },
200+
type: { name: 'number' },
201+
table: {
202+
type: {
203+
summary: 'number',
204+
},
205+
category: CATEGORY_CONTROL.MODIFIERS,
206+
},
207+
},
208+
['aria-label']: {
209+
description: 'Input aria-label',
210+
control: { type: 'text' },
211+
type: { name: 'string' },
212+
table: {
213+
type: {
214+
summary: 'string',
215+
},
216+
category: CATEGORY_CONTROL.ACCESIBILITY,
217+
},
218+
},
219+
['aria-labelledby']: {
220+
description: 'Input aria-labelledby',
221+
control: { type: 'text' },
222+
type: { name: 'string' },
223+
table: {
224+
type: {
225+
summary: 'string',
226+
},
227+
category: CATEGORY_CONTROL.ACCESIBILITY,
228+
},
229+
},
230+
['aria-hidden']: {
231+
description: 'Hide element from screen readers',
232+
control: { type: 'boolean' },
233+
type: { name: 'boolean' },
234+
table: {
235+
type: {
236+
summary: 'boolean',
237+
},
238+
category: CATEGORY_CONTROL.ACCESIBILITY,
239+
},
240+
},
197241
dataTestId: {
198242
description: 'String used for testing',
199243
control: { type: 'text' },

src/components/checkbox/types/checkbox.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ export interface ICheckboxErrorStandAlone {
3434
errorMessage?: CheckboxHelperAndErrorTextType;
3535
}
3636

37-
type CheckboxAriaAttributes = Pick<React.AriaAttributes, 'aria-label' | 'aria-labelledby'>;
37+
type CheckboxAriaAttributes = Pick<
38+
React.AriaAttributes,
39+
'aria-label' | 'aria-labelledby' | 'aria-hidden'
40+
>;
3841

3942
/**
4043
* @description
@@ -56,6 +59,7 @@ export interface ICheckboxStandAlone extends IInputComponent, CheckboxAriaAttrib
5659
helperText?: CheckboxHelperAndErrorTextType;
5760
extraAriaDescribedBy?: string;
5861
screenReaderText?: string;
62+
tabIndex?: number;
5963
}
6064

6165
/**

0 commit comments

Comments
 (0)