Skip to content

Commit 3f03500

Browse files
committed
feat: TabGroup - add support for disabled tab
1 parent bea90fd commit 3f03500

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/Shared/Components/TabGroup/TabGroup.component.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const Tab = ({
2121
showIndicator,
2222
showError,
2323
showWarning,
24+
disabled,
2425
}: TabProps & Pick<TabGroupProps, 'size' | 'alignActiveBorderWithContainer' | 'hideTopPadding'>) => {
2526
const getClassNameBySize = () => {
2627
switch (size) {
@@ -62,7 +63,8 @@ const Tab = ({
6263
case 'link':
6364
return (
6465
<Link
65-
className={`${tabClassName} dc__no-decor flexbox dc__align-items-center dc__gap-6`}
66+
className={`${tabClassName} dc__no-decor flexbox dc__align-items-center dc__gap-6 ${disabled ? 'cursor-not-allowed' : ''}`}
67+
aria-disabled={disabled}
6668
{...props}
6769
>
6870
{content}
@@ -71,7 +73,8 @@ const Tab = ({
7173
case 'navLink':
7274
return (
7375
<NavLink
74-
className={`${tabClassName} dc__no-decor tab-group__tab__nav-link flexbox dc__align-items-center dc__gap-6`}
76+
className={`${tabClassName} dc__no-decor tab-group__tab__nav-link flexbox dc__align-items-center dc__gap-6 ${disabled ? 'cursor-not-allowed' : ''}`}
77+
aria-disabled={disabled}
7578
{...props}
7679
>
7780
{content}
@@ -81,7 +84,8 @@ const Tab = ({
8184
return (
8285
<button
8386
type="button"
84-
className={`dc__unset-button-styles ${tabClassName} flexbox dc__align-items-center dc__gap-6`}
87+
className={`dc__unset-button-styles ${tabClassName} flexbox dc__align-items-center dc__gap-6 ${disabled ? 'cursor-not-allowed' : ''}`}
88+
disabled={disabled}
8589
{...props}
8690
>
8791
{content}

src/Shared/Components/TabGroup/TabGroup.types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ export type TabProps = {
8585
* @note error state will take precedence over warning state.
8686
*/
8787
showError?: boolean
88+
/**
89+
* Disables the tab, preventing interaction and indicating an inactive state.
90+
*/
91+
disabled?: boolean
8892
} & ConditionalTabType
8993

9094
export interface TabGroupProps {

0 commit comments

Comments
 (0)