diff --git a/change/@fluentui-react-tabs-509e61ea-8dad-490f-9503-54f49362f231.json b/change/@fluentui-react-tabs-509e61ea-8dad-490f-9503-54f49362f231.json
new file mode 100644
index 00000000000000..7235490c904342
--- /dev/null
+++ b/change/@fluentui-react-tabs-509e61ea-8dad-490f-9503-54f49362f231.json
@@ -0,0 +1,7 @@
+{
+ "type": "patch",
+ "comment": "Added support for regular/filled icon toggling",
+ "packageName": "@fluentui/react-tabs",
+ "email": "gcox@microsoft.com",
+ "dependentChangeType": "patch"
+}
diff --git a/packages/react-components/react-tabs/src/components/Tab/useTabStyles.ts b/packages/react-components/react-tabs/src/components/Tab/useTabStyles.ts
index 26a71ad563ec13..059d83d897aab8 100644
--- a/packages/react-components/react-tabs/src/components/Tab/useTabStyles.ts
+++ b/packages/react-components/react-tabs/src/components/Tab/useTabStyles.ts
@@ -16,6 +16,13 @@ const reservedSpaceClassNames = {
content: 'fui-Tab__content--reserved-space',
};
+// These should match the constants defined in @fluentui/react-icons
+// This package avoids taking a dependency on the icons package for only the constants.
+const iconClassNames = {
+ filled: 'fui-Icon-filled',
+ regular: 'fui-Icon-regular',
+};
+
/**
* Styles for the root slot
*/
@@ -360,6 +367,12 @@ const useIconStyles = makeStyles({
display: 'inline-flex',
justifyContent: 'center',
...shorthands.overflow('hidden'),
+ [`& .${iconClassNames.filled}`]: {
+ display: 'none',
+ },
+ [`& .${iconClassNames.regular}`]: {
+ display: 'inline',
+ },
},
// per design, the small and medium font sizes are the same.
// the size prop only affects spacing.
@@ -378,6 +391,14 @@ const useIconStyles = makeStyles({
height: '24px',
width: '24px',
},
+ selected: {
+ [`& .${iconClassNames.filled}`]: {
+ display: 'inline',
+ },
+ [`& .${iconClassNames.regular}`]: {
+ display: 'none',
+ },
+ },
});
/**
@@ -463,7 +484,13 @@ export const useTabStyles_unstable = (state: TabState): TabState => {
);
if (state.icon) {
- state.icon.className = mergeClasses(tabClassNames.icon, iconStyles.base, iconStyles[size], state.icon.className);
+ state.icon.className = mergeClasses(
+ tabClassNames.icon,
+ iconStyles.base,
+ iconStyles[size],
+ selected && iconStyles.selected,
+ state.icon.className,
+ );
}
// This needs to be before state.content.className is updated
diff --git a/packages/react-components/react-tabs/stories/Tabs/TabListDisabled.stories.tsx b/packages/react-components/react-tabs/stories/Tabs/TabListDisabled.stories.tsx
index 9d04cca2a10f9f..391a24613174a5 100644
--- a/packages/react-components/react-tabs/stories/Tabs/TabListDisabled.stories.tsx
+++ b/packages/react-components/react-tabs/stories/Tabs/TabListDisabled.stories.tsx
@@ -1,6 +1,8 @@
import * as React from 'react';
-import { CalendarMonthRegular } from '@fluentui/react-icons';
import { makeStyles, shorthands, Tab, TabList } from '@fluentui/react-components';
+import { CalendarMonthRegular, CalendarMonthFilled, bundleIcon } from '@fluentui/react-icons';
+
+const CalendarMonth = bundleIcon(CalendarMonthFilled, CalendarMonthRegular);
const useStyles = makeStyles({
root: {
@@ -19,30 +21,30 @@ export const Disabled = () => {
return (
- } value="tab1">
+ } value="tab1">
First Tab
- } value="tab2">
+ } value="tab2">
Second Tab
- } value="tab3">
+ } value="tab3">
Third Tab
- } value="tab4">
+ } value="tab4">
Fourth Tab
- } value="tab1">
+ } value="tab1">
First Tab
- } value="tab2" disabled>
+ } value="tab2" disabled>
Second Tab
- } value="tab3" disabled>
+ } value="tab3" disabled>
Third Tab
- } value="tab4">
+ } value="tab4">
Fourth Tab
diff --git a/packages/react-components/react-tabs/stories/Tabs/TabListIconOnly.stories.tsx b/packages/react-components/react-tabs/stories/Tabs/TabListIconOnly.stories.tsx
index 3784a927662d0f..2558cbd7d6692d 100644
--- a/packages/react-components/react-tabs/stories/Tabs/TabListIconOnly.stories.tsx
+++ b/packages/react-components/react-tabs/stories/Tabs/TabListIconOnly.stories.tsx
@@ -1,6 +1,8 @@
import * as React from 'react';
import { makeStyles, shorthands, Tab, TabList } from '@fluentui/react-components';
-import { CalendarMonthRegular } from '@fluentui/react-icons';
+import { CalendarMonthRegular, CalendarMonthFilled, bundleIcon } from '@fluentui/react-icons';
+
+const CalendarMonth = bundleIcon(CalendarMonthFilled, CalendarMonthRegular);
const useStyles = makeStyles({
root: {
@@ -19,10 +21,10 @@ export const IconOnly = () => {
const renderTabs = () => {
return (
<>
-
} value="tab1" aria-label="First Tab" />
-
} value="tab2" aria-label="Second Tab" />
-
} value="tab3" aria-label="Third Tab" />
-
} value="tab4" aria-label="Fourth Tab" />
+
} value="tab1" aria-label="First Tab" />
+
} value="tab2" aria-label="Second Tab" />
+
} value="tab3" aria-label="Third Tab" />
+
} value="tab4" aria-label="Fourth Tab" />
>
);
};
diff --git a/packages/react-components/react-tabs/stories/Tabs/TabListSizeLarge.stories.tsx b/packages/react-components/react-tabs/stories/Tabs/TabListSizeLarge.stories.tsx
index 41e7ddfe4186f6..a49ec82f300053 100644
--- a/packages/react-components/react-tabs/stories/Tabs/TabListSizeLarge.stories.tsx
+++ b/packages/react-components/react-tabs/stories/Tabs/TabListSizeLarge.stories.tsx
@@ -1,6 +1,8 @@
import * as React from 'react';
-import { CalendarMonthRegular } from '@fluentui/react-icons';
import { makeStyles, shorthands, Tab, TabList } from '@fluentui/react-components';
+import { CalendarMonthRegular, CalendarMonthFilled, bundleIcon } from '@fluentui/react-icons';
+
+const CalendarMonth = bundleIcon(CalendarMonthFilled, CalendarMonthRegular);
const useStyles = makeStyles({
root: {
@@ -20,7 +22,7 @@ export const SizeLarge = () => {
return (
<>
First Tab
-
} value="tab2">
+
} value="tab2">
Second Tab
Third Tab
diff --git a/packages/react-components/react-tabs/stories/Tabs/TabListSizeMedium.stories.tsx b/packages/react-components/react-tabs/stories/Tabs/TabListSizeMedium.stories.tsx
index b58ee623a6b27f..fc9ccc9644dbdd 100644
--- a/packages/react-components/react-tabs/stories/Tabs/TabListSizeMedium.stories.tsx
+++ b/packages/react-components/react-tabs/stories/Tabs/TabListSizeMedium.stories.tsx
@@ -1,6 +1,8 @@
import * as React from 'react';
-import { CalendarMonthRegular } from '@fluentui/react-icons';
import { makeStyles, shorthands, Tab, TabList } from '@fluentui/react-components';
+import { CalendarMonthRegular, CalendarMonthFilled, bundleIcon } from '@fluentui/react-icons';
+
+const CalendarMonth = bundleIcon(CalendarMonthFilled, CalendarMonthRegular);
const useStyles = makeStyles({
root: {
@@ -20,7 +22,7 @@ export const SizeMedium = () => {
return (
<>
First Tab
-
} value="tab2">
+
} value="tab2">
Second Tab
Third Tab
diff --git a/packages/react-components/react-tabs/stories/Tabs/TabListSizeSmall.stories.tsx b/packages/react-components/react-tabs/stories/Tabs/TabListSizeSmall.stories.tsx
index f8814b6cca3a18..5f42c51ffc0b3c 100644
--- a/packages/react-components/react-tabs/stories/Tabs/TabListSizeSmall.stories.tsx
+++ b/packages/react-components/react-tabs/stories/Tabs/TabListSizeSmall.stories.tsx
@@ -1,6 +1,8 @@
import * as React from 'react';
-import { CalendarMonthRegular } from '@fluentui/react-icons';
import { makeStyles, shorthands, Tab, TabList } from '@fluentui/react-components';
+import { CalendarMonthRegular, CalendarMonthFilled, bundleIcon } from '@fluentui/react-icons';
+
+const CalendarMonth = bundleIcon(CalendarMonthFilled, CalendarMonthRegular);
const useStyles = makeStyles({
root: {
@@ -20,7 +22,7 @@ export const SizeSmall = () => {
return (
<>
First Tab
-
} value="tab2">
+
} value="tab2">
Second Tab
Third Tab
diff --git a/packages/react-components/react-tabs/stories/Tabs/TabListWithIcon.stories.tsx b/packages/react-components/react-tabs/stories/Tabs/TabListWithIcon.stories.tsx
index d0cec89484a6f2..21e8aad3d0de1b 100644
--- a/packages/react-components/react-tabs/stories/Tabs/TabListWithIcon.stories.tsx
+++ b/packages/react-components/react-tabs/stories/Tabs/TabListWithIcon.stories.tsx
@@ -1,6 +1,8 @@
import * as React from 'react';
import { makeStyles, shorthands, Tab, TabList } from '@fluentui/react-components';
-import { CalendarMonthRegular } from '@fluentui/react-icons';
+import { CalendarMonthRegular, CalendarMonthFilled, bundleIcon } from '@fluentui/react-icons';
+
+const CalendarMonth = bundleIcon(CalendarMonthFilled, CalendarMonthRegular);
const useStyles = makeStyles({
root: {
@@ -19,16 +21,16 @@ export const WithIcon = () => {
const renderTabs = () => {
return (
<>
-
} value="tab1">
+
} value="tab1">
First Tab
-
} value="tab2">
+
} value="tab2">
Second Tab
-
} value="tab3">
+
} value="tab3">
Third Tab
-
} value="tab4">
+
} value="tab4">
Fourth Tab
>
diff --git a/packages/react-components/react-tabs/stories/Tabs/TabListWithOverflow.stories.tsx b/packages/react-components/react-tabs/stories/Tabs/TabListWithOverflow.stories.tsx
index cf1a82741c3e3a..3d49411ce603c3 100644
--- a/packages/react-components/react-tabs/stories/Tabs/TabListWithOverflow.stories.tsx
+++ b/packages/react-components/react-tabs/stories/Tabs/TabListWithOverflow.stories.tsx
@@ -25,10 +25,32 @@ import {
CalendarWeekStartRegular,
CalendarWorkWeekRegular,
MoreHorizontalRegular,
+ Calendar3DayFilled,
+ CalendarAgendaFilled,
+ CalendarChatFilled,
+ CalendarDayFilled,
+ CalendarMonthFilled,
+ CalendarSearchFilled,
+ CalendarTodayFilled,
+ CalendarWeekStartFilled,
+ CalendarWorkWeekFilled,
+ MoreHorizontalFilled,
+ bundleIcon,
} from '@fluentui/react-icons';
import { useIsOverflowItemVisible, useOverflowMenu, Overflow, OverflowItem } from '@fluentui/react-overflow';
import type { ARIAButtonElement } from '@fluentui/react-aria';
+const Calendar3Day = bundleIcon(Calendar3DayFilled, Calendar3DayRegular);
+const CalendarAgenda = bundleIcon(CalendarAgendaFilled, CalendarAgendaRegular);
+const CalendarChat = bundleIcon(CalendarChatFilled, CalendarChatRegular);
+const CalendarDay = bundleIcon(CalendarDayFilled, CalendarDayRegular);
+const CalendarMonth = bundleIcon(CalendarMonthFilled, CalendarMonthRegular);
+const CalendarSearch = bundleIcon(CalendarSearchFilled, CalendarSearchRegular);
+const CalendarToday = bundleIcon(CalendarTodayFilled, CalendarTodayRegular);
+const CalendarWeekStart = bundleIcon(CalendarWeekStartFilled, CalendarWeekStartRegular);
+const CalendarWorkWeek = bundleIcon(CalendarWorkWeekFilled, CalendarWorkWeekRegular);
+const MoreHorizontal = bundleIcon(MoreHorizontalFilled, MoreHorizontalRegular);
+
//----- Example Tab Data -----//
type ExampleTab = {
@@ -41,47 +63,47 @@ const tabs: ExampleTab[] = [
{
id: 'today',
name: 'Today',
- icon:
,
+ icon:
,
},
{
id: 'agenda',
name: 'Agenda',
- icon:
,
+ icon:
,
},
{
id: 'day',
name: 'Day',
- icon:
,
+ icon:
,
},
{
id: 'threeDay',
name: 'Three Day',
- icon:
,
+ icon:
,
},
{
id: 'workWeek',
name: 'Work Week',
- icon:
,
+ icon:
,
},
{
id: 'week',
name: 'Week',
- icon:
,
+ icon:
,
},
{
id: 'month',
name: 'Month',
- icon:
,
+ icon:
,
},
{
id: 'search',
name: 'Search',
- icon:
,
+ icon:
,
},
{
id: 'chat',
name: 'Conversations',
- icon:
,
+ icon:
,
},
];
@@ -149,7 +171,7 @@ const OverflowMenu = (props: OverflowMenuProps) => {
appearance="transparent"
className={styles.menuButton}
ref={ref}
- icon={
}
+ icon={
}
aria-label={`${overflowCount} more tabs`}
role="tab"
/>
diff --git a/packages/react-components/react-tabs/stories/Tabs/TabListWithPanels.stories.tsx b/packages/react-components/react-tabs/stories/Tabs/TabListWithPanels.stories.tsx
index 39d5b3d9c4bde4..0514f8c39a82cc 100644
--- a/packages/react-components/react-tabs/stories/Tabs/TabListWithPanels.stories.tsx
+++ b/packages/react-components/react-tabs/stories/Tabs/TabListWithPanels.stories.tsx
@@ -1,8 +1,20 @@
import * as React from 'react';
import { makeStyles, shorthands, tokens, Tab, TabList } from '@fluentui/react-components';
-import { AirplaneRegular, AirplaneTakeOffRegular, TimeAndWeatherRegular } from '@fluentui/react-icons';
+import {
+ AirplaneRegular,
+ AirplaneFilled,
+ AirplaneTakeOffRegular,
+ AirplaneTakeOffFilled,
+ TimeAndWeatherRegular,
+ TimeAndWeatherFilled,
+ bundleIcon,
+} from '@fluentui/react-icons';
import type { SelectTabData, SelectTabEvent, TabValue } from '@fluentui/react-components';
+const Airplane = bundleIcon(AirplaneFilled, AirplaneRegular);
+const AirplaneTakeOff = bundleIcon(AirplaneTakeOffFilled, AirplaneTakeOffRegular);
+const TimeAndWeather = bundleIcon(TimeAndWeatherFilled, TimeAndWeatherRegular);
+
const useStyles = makeStyles({
root: {
alignItems: 'flex-start',
@@ -124,13 +136,13 @@ export const WithPanels = () => {
return (
- } value="arrivals">
+ } value="arrivals">
Arrivals
- } value="departures">
+ } value="departures">
Departures
- } value="conditions">
+ } value="conditions">
Conditions