Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export namespace TabsProps {
content: ReactNode;
isDefault?: boolean;
disabled?: boolean;
ariaLabel?: string;
title?: string;
}[];
selectedTabId?: undefined;
onTabChange?: (params: { tabIndex: number; tab: Uncontrolled["tabs"][number] }) => void;
Expand All @@ -40,6 +42,8 @@ export namespace TabsProps {
label: ReactNode;
iconId?: FrIconClassName | RiIconClassName;
disabled?: boolean;
ariaLabel?: string;
title?: string;
}[];
selectedTabId: string;
onTabChange: (tabId: string) => void;
Expand Down Expand Up @@ -141,7 +145,7 @@ export const Tabs = memo(
aria-label={label}
onKeyDownCapture={e => onKeyboardNavigation(e)}
>
{tabs.map(({ label, iconId, disabled }, tabIndex) => (
{tabs.map(({ label, iconId, disabled, ariaLabel, title }, tabIndex) => (
<li key={tabIndex} role="presentation">
<button
ref={button => (buttonRefs.current[tabIndex] = button)}
Expand All @@ -157,6 +161,8 @@ export const Tabs = memo(
aria-controls={getPanelId(tabIndex)}
onClick={onTabClickFactory(tabIndex)}
disabled={disabled}
aria-label={ariaLabel}
title={title}
>
{label}
</button>
Expand Down
22 changes: 22 additions & 0 deletions stories/Tabs.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,25 @@ export const WithTab2OpenedByDefault = getStory({
"label": "Name of the tabs system",
...logCallbacks(["onTabChange"])
});

export const WithAriaLabelAndTitle = getStory({
"tabs": [
{
"label": "Tab 1",
"iconId": "fr-icon-add-line",
"content": <p>Content of tab1</p>,
"ariaLabel": "First tab, add content",
"title": "Add content"
},
{
"label": "Tab 2",
"iconId": "fr-icon-ball-pen-fill",
"content": <p>Content of tab2</p>,
"ariaLabel": "Second tab, edit content",
"title": "Edit content"
},
{ "label": "Tab 3", "content": <p>Content of tab3</p> }
],
"label": "Tabs with aria-label and title attributes",
...logCallbacks(["onTabChange"])
});