Skip to content

Conversation

@Hotell
Copy link
Collaborator

@Hotell Hotell commented Jan 20, 2026

Introduces another public api endpoint for svg related utilities to improve tree-shaking and bundle size -> @fluentui/react-icons/utils

Before:

import {AccessTimeFilled, AccessTimeRegular} from '@fluentui/react-icons/svg/access-time';
import {bundleIcon, iconRegularClassName} from '@fluentui/react-icons';

const Bundled = bundleIcon(AccessTimeFilled,AccessTimeRegular);

After

import {AccessTimeFilled, AccessTimeRegular} from '@fluentui/react-icons/svg/access-time'
// 🚢 NEW api
import {bundleIcon, iconRegularClassName} from '@fluentui/react-icons/utils';

const Bundled = bundleIcon(AccessTimeFilled,AccessTimeRegular);

Additional changes

  • changes bundleIcon from default to named export for better three shaking
  • fixes invalid custom filled property propagation to <svg>

@Hotell Hotell marked this pull request as ready for review January 21, 2026 10:08
@Hotell Hotell requested review from a team as code owners January 21, 2026 10:08
@Hotell Hotell requested a review from dmytrokirpa January 21, 2026 10:09
}

export default bundleIcon;
export const bundleIcon = (FilledIcon: FluentIcon, RegularIcon: FluentIcon): FluentIcon => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added only explicit return annotation - the body was reformatted by prettier

dmytrokirpa
dmytrokirpa previously approved these changes Jan 21, 2026
* Whether to render the filled version of the icon.
* NOTE: This prop is only applicable when using bundled icons created with `bundleIcon`.
*/
filled?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to have two separate types like:

export type FluentIconsProps<
  TBaseAttributes extends
    | React.SVGAttributes<SVGElement>
    | React.HTMLAttributes<HTMLElement> = React.SVGAttributes<SVGElement>,
  TRefType extends HTMLElement | SVGSVGElement = SVGSVGElement,
> = TBaseAttributes &
  React.RefAttributes<TRefType> & {
    primaryFill?: string;
    className?: string;
    title?: string;
}

export type FluentCompoundIconProps<
  TBaseAttributes extends
    | React.SVGAttributes<SVGElement>
    | React.HTMLAttributes<HTMLElement> = React.SVGAttributes<SVGElement>,
  TRefType extends HTMLElement | SVGSVGElement = SVGSVGElement,
> = FluentIconsProps<TBaseAttributes> & {
/**
     * Whether to render the filled version of the icon.
     */
    filled?: boolean;
}

Copy link
Collaborator Author

@Hotell Hotell Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it does, but if we do this it would break user pipeline if someone "by accident" set filled on normal icon

@Hotell Hotell force-pushed the react-icons/export-map-utils branch from 04b9f91 to 108cf7c Compare January 30, 2026 15:46
@Hotell Hotell merged commit 1c786a9 into microsoft:main Jan 30, 2026
7 checks passed
@Hotell Hotell deleted the react-icons/export-map-utils branch January 30, 2026 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants