Skip to content

Commit 152a0f7

Browse files
committed
feat(Tabs): add ariaLabel and ariaLabelledby to improve accessibility
BREAKING CHANGE: TabList component no longer sets the default aria-label value. You can provide the value via ariaLabel or ariaLabelledby prop.
1 parent 006e249 commit 152a0f7

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

packages/orbit-components/src/Tabs/README.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@ Table below contains all types of the props available in Tabs component.
4242

4343
Table below contains all types of the props available in TabList component.
4444

45-
| Name | Type | Default | Description |
46-
| :-------- | :-------------- | :------ | :----------------------------------------------------------------------------------- |
47-
| dataTest | `string` | | Optional prop for testing purposes. |
48-
| children | `React.node` | | Required prop that should contain the `Tab` components. |
49-
| compact | `boolean` | `false` | Optional prop that responsible for `Tab`size, if provided, the Tabs will be smaller. |
50-
| spacing | [`enum`](#enum) | `none` | Optional prop to set gap between `Tab` elements. |
51-
| fullWidth | `boolean` | `false` | Optional prop to set `TabList` to full width. |
45+
| Name | Type | Default | Description |
46+
| :------------- | :-------------- | :------ | :----------------------------------------------------------------------------------- |
47+
| dataTest | `string` | | Optional prop for testing purposes. |
48+
| children | `React.node` | | Required prop that should contain the `Tab` components. |
49+
| compact | `boolean` | `false` | Optional prop that responsible for `Tab`size, if provided, the Tabs will be smaller. |
50+
| spacing | [`enum`](#enum) | `none` | Optional prop to set gap between `Tab` elements. |
51+
| fullWidth | `boolean` | `false` | Optional prop to set `TabList` to full width. |
52+
| ariaLabel | `string` | | Optional prop for `aria-label`. |
53+
| ariaLabelledBy | `string` | | Optional prop for `aria-labelledby`. |
5254

5355
### Tab
5456

packages/orbit-components/src/Tabs/components/TabList/index.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ const TabList = ({
1515
margin,
1616
dataTest,
1717
fullWidth,
18+
ariaLabel,
19+
ariaLabelledby,
1820
}: Props) => {
1921
const cssVars = {
2022
"--tab-list-padding": typeof padding === "string" ? padding : undefined,
@@ -45,7 +47,8 @@ const TabList = ({
4547
cssVars["--tab-list-margin-left"] && "ms-[var(--tab-list-margin-left)]",
4648
)}
4749
role="tablist"
48-
aria-label="tabs"
50+
aria-label={ariaLabel}
51+
aria-labelledby={ariaLabelledby}
4952
data-test={dataTest}
5053
style={cssVars}
5154
>

packages/orbit-components/src/Tabs/components/TabList/types.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ export interface Props extends Globals {
1010
compact?: boolean;
1111
margin?: React.CSSProperties["margin"] | ObjectProperty;
1212
padding?: React.CSSProperties["padding"] | ObjectProperty;
13+
ariaLabel?: string;
14+
ariaLabelledby?: string;
1315
}

0 commit comments

Comments
 (0)