Skip to content

feat(react-headless-components-preview): add headless MenuButton#36320

Open
mainframev wants to merge 8 commits into
microsoft:masterfrom
mainframev:feat/headless-menu-button
Open

feat(react-headless-components-preview): add headless MenuButton#36320
mainframev wants to merge 8 commits into
microsoft:masterfrom
mainframev:feat/headless-menu-button

Conversation

@mainframev

@mainframev mainframev commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Description

Adds a headless, unstyled MenuButton to @fluentui/react-headless-components-preview, following the same pattern as the existing headless Button and ToggleButton: it consumes useMenuButtonBase_unstable from @fluentui/react-button and adds data-* styling-hook attributes, re-exporting the shared renderMenuButton_unstable.

⚠️ Stacked on #36319 (the react-button base hook). This PR is a Draft until #36319 merges. Until then its diff also shows the react-button changes from #36319 — once that lands I'll rebase this branch onto master, leaving only the headless additions below.

@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-button
MenuButton
37.588 kB
9.892 kB
37.615 kB
9.91 kB
27 B
18 B
react-button
SplitButton
46.556 kB
11.533 kB
46.584 kB
11.551 kB
28 B
18 B
react-charts
AreaChart
404.498 kB
126.128 kB
404.526 kB
126.136 kB
28 B
8 B
react-charts
DeclarativeChart
755.499 kB
220.495 kB
755.527 kB
220.52 kB
28 B
25 B
react-charts
DonutChart
314.961 kB
96.878 kB
314.989 kB
96.884 kB
28 B
6 B
react-charts
FunnelChart
306.46 kB
93.69 kB
306.488 kB
93.707 kB
28 B
17 B
react-charts
GanttChart
387.595 kB
120.492 kB
387.622 kB
120.513 kB
27 B
21 B
react-charts
GaugeChart
314.339 kB
96.25 kB
314.367 kB
96.27 kB
28 B
20 B
react-charts
GroupedVerticalBarChart
395.467 kB
123.213 kB
395.495 kB
123.234 kB
28 B
21 B
react-charts
HeatMapChart
389.674 kB
121.531 kB
389.702 kB
121.546 kB
28 B
15 B
react-charts
HorizontalBarChart
294.633 kB
89.357 kB
294.661 kB
89.371 kB
28 B
14 B
react-charts
Legends
234.31 kB
70.189 kB
234.338 kB
70.187 kB
28 B
-2 B
react-charts
LineChart
415.826 kB
129.097 kB
415.854 kB
129.142 kB
28 B
45 B
react-charts
PolarChart
343.31 kB
106.743 kB
343.338 kB
106.751 kB
28 B
8 B
react-charts
ScatterChart
395.209 kB
123.217 kB
395.237 kB
123.235 kB
28 B
18 B
react-charts
VerticalBarChart
431.947 kB
128.17 kB
431.975 kB
128.182 kB
28 B
12 B
react-charts
VerticalStackedBarChart
401.671 kB
124.635 kB
401.699 kB
124.665 kB
28 B
30 B
react-components
react-components: entire library
1.296 MB
325.606 kB
1.296 MB
325.645 kB
35 B
39 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-breadcrumb
@fluentui/react-breadcrumb - package
102.926 kB
28.76 kB
react-button
Button
32.684 kB
8.504 kB
react-button
CompoundButton
39.562 kB
9.861 kB
react-button
ToggleButton
52.344 kB
10.635 kB
react-card
Card - All
93.06 kB
26.955 kB
react-card
Card
85.658 kB
25.044 kB
react-card
CardFooter
11.516 kB
4.606 kB
react-card
CardHeader
14.047 kB
5.435 kB
react-card
CardPreview
11.597 kB
4.716 kB
react-charts
HorizontalBarChartWithAxis
63 B
83 B
react-charts
SankeyChart
211.914 kB
67.836 kB
react-charts
Sparkline
80.503 kB
26.644 kB
react-components
react-components: Button, FluentProvider & webLightTheme
66.328 kB
19.02 kB
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
226.531 kB
68.074 kB
react-components
react-components: FluentProvider & webLightTheme
39.525 kB
13.113 kB
react-dialog
Dialog (including children components)
90.204 kB
27.895 kB
react-headless-components-preview
react-headless-components-preview: entire library
248.544 kB
71.466 kB
react-message-bar
MessageBar (all components)
22.306 kB
8.184 kB
react-portal-compat
PortalCompatProvider
5.567 kB
2.237 kB
react-tag-picker
@fluentui/react-tag-picker - package
174.152 kB
54.127 kB
react-teaching-popover
TeachingPopover
101.1 kB
31.859 kB
react-timepicker-compat
TimePicker
141.076 kB
46.036 kB
react-tree
FlatTree
135.901 kB
40.452 kB
react-tree
PersonaFlatTree
137.729 kB
40.967 kB
react-tree
PersonaTree
133.79 kB
39.741 kB
react-tree
Tree
131.968 kB
39.256 kB
🤖 This report was generated against 19d82d85bda458b0af3fa4e0814bf3232fc78594

@github-actions

Copy link
Copy Markdown

Pull request demo site: URL

@mainframev mainframev self-assigned this Jun 17, 2026
@mainframev mainframev force-pushed the feat/headless-menu-button branch 5 times, most recently from 30449c8 to 7a064fa Compare June 17, 2026 21:16
@mainframev mainframev marked this pull request as ready for review June 18, 2026 11:55
@mainframev mainframev requested a review from a team as a code owner June 18, 2026 11:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new headless, unstyled MenuButton surface to @fluentui/react-headless-components-preview, built on top of a new useMenuButtonBase_unstable base hook in @fluentui/react-button (this PR is currently stacked on #36319 per the description).

Changes:

  • Add headless MenuButton implementation, exports, stories, and API report for @fluentui/react-headless-components-preview/menu-button.
  • Add useMenuButtonBase_unstable + base types in @fluentui/react-button, and widen renderMenuButton_unstable to accept MenuButtonBaseState.
  • Add tests and beachball change files for both packages.

Reviewed changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/react-components/react-headless-components-preview/stories/src/MenuButton/MenuButtonWithIcon.stories.tsx Adds icon + icon-only story variants for headless MenuButton.
packages/react-components/react-headless-components-preview/stories/src/MenuButton/MenuButtonSize.stories.tsx Adds size styling examples for headless MenuButton.
packages/react-components/react-headless-components-preview/stories/src/MenuButton/MenuButtonDisabled.stories.tsx Adds disabled/disabledFocusable examples for headless MenuButton.
packages/react-components/react-headless-components-preview/stories/src/MenuButton/MenuButtonDescription.md Adds docs description for the new headless MenuButton stories page.
packages/react-components/react-headless-components-preview/stories/src/MenuButton/MenuButtonDefault.stories.tsx Adds default usage story (as Menu trigger).
packages/react-components/react-headless-components-preview/stories/src/MenuButton/MenuButtonAppearance.stories.tsx Adds appearance styling examples (primary/secondary/subtle/outline) via CSS classes.
packages/react-components/react-headless-components-preview/stories/src/MenuButton/menu-button.module.css Adds story-only styling using CSS variables and data-* hooks.
packages/react-components/react-headless-components-preview/stories/src/MenuButton/index.stories.tsx Registers MenuButton stories under Components/MenuButton.
packages/react-components/react-headless-components-preview/library/src/menu-button.ts Adds the package entrypoint re-export for menu-button subpath.
packages/react-components/react-headless-components-preview/library/src/components/MenuButton/useMenuButton.ts Implements headless useMenuButton wrapper to add data-* styling hooks.
packages/react-components/react-headless-components-preview/library/src/components/MenuButton/renderMenuButton.ts Re-exports shared renderMenuButton_unstable from @fluentui/react-button.
packages/react-components/react-headless-components-preview/library/src/components/MenuButton/MenuButton.types.ts Defines headless MenuButtonState augmentation and re-exports props/slots.
packages/react-components/react-headless-components-preview/library/src/components/MenuButton/MenuButton.tsx Adds headless MenuButton component wrapper (ForwardRefComponent).
packages/react-components/react-headless-components-preview/library/src/components/MenuButton/MenuButton.test.tsx Adds headless component conformance + basic rendering/state tests.
packages/react-components/react-headless-components-preview/library/src/components/MenuButton/index.ts Adds component-level barrel exports for headless MenuButton.
packages/react-components/react-headless-components-preview/library/package.json Adds "./menu-button" export map entry.
packages/react-components/react-headless-components-preview/library/etc/menu-button.api.md Adds API Extractor report output for the new headless menu-button entrypoint.
packages/react-components/react-button/library/src/MenuButton.ts Re-exports new base hook + base types for public consumption.
packages/react-components/react-button/library/src/index.ts Adds new base hook + base types exports at package root.
packages/react-components/react-button/library/src/components/MenuButton/useMenuButtonBase.test.tsx Adds unit tests for useMenuButtonBase_unstable.
packages/react-components/react-button/library/src/components/MenuButton/useMenuButton.tsx Implements useMenuButtonBase_unstable and refactors useMenuButton_unstable to build on it.
packages/react-components/react-button/library/src/components/MenuButton/renderMenuButton.tsx Widens render signature from styled state to base state.
packages/react-components/react-button/library/src/components/MenuButton/MenuButton.types.ts Adds MenuButtonBaseProps/MenuButtonBaseState for headless composition.
packages/react-components/react-button/library/src/components/MenuButton/index.ts Exports new base hook + base types from component barrel.
packages/react-components/react-button/library/etc/react-button.api.md Updates public API report for new base hook/types and widened render signature.
change/@fluentui-react-headless-components-preview-7246c651-b258-4694-b0e7-45b666b15aae.json Adds beachball change entry for headless MenuButton.
change/@fluentui-react-button-3e45fb7a-a8fa-4902-a694-fa9b89a68fd1.json Adds beachball change entry for new useMenuButtonBase_unstable.

@mainframev mainframev force-pushed the feat/headless-menu-button branch from 43c60bc to bbae420 Compare June 19, 2026 13:28
@mainframev mainframev force-pushed the feat/headless-menu-button branch 2 times, most recently from 095e38d to 2f632b1 Compare June 22, 2026 15:05
@mainframev mainframev force-pushed the feat/headless-menu-button branch 2 times, most recently from cfda883 to 7c01449 Compare June 23, 2026 11:59
@mainframev mainframev force-pushed the feat/headless-menu-button branch 4 times, most recently from ca34a5b to e58accd Compare June 23, 2026 13:16
@mainframev mainframev force-pushed the feat/headless-menu-button branch from e58accd to 751ea98 Compare June 23, 2026 13:56
@mainframev mainframev force-pushed the feat/headless-menu-button branch from 751ea98 to a68bf14 Compare June 23, 2026 13:59
const { appearance = 'secondary', shape = 'rounded', size = contextSize ?? 'medium', ...baseProps } = props;
const baseState = useMenuButtonBase_unstable(baseProps, ref);

if (baseState.menuIcon) {

@dmytrokirpa dmytrokirpa Jun 24, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I know we have a similar approach in a few other places, but we need to fix that.

  • can we use something like:
const baseState = useMenuButtonBase_unstable({
  ...baseProps,
  menuIcon: { children: <ChevronDownRegular />, ...slot.resolveShorthand(props.menuIcon) }
}, ref);

  • and move this change to a separate PR?

@mainframev mainframev Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good call. I moved this react-button change into a dedicated PR that should merge before this one: #36345

…on directly from react-button

Addresses review feedback to use a direct re-export instead of an
import + const alias, matching the suggestion on the PR.
…on_unstable

Align with the standalone react-button PR (microsoft#36345). Replaces the post-hoc
mutation of baseState.menuIcon with passing a null-safe default into
useMenuButtonBase_unstable, so menuIcon={null} still hides the icon.

This react-button change is owned by microsoft#36345 and will drop out of this
branch once microsoft#36345 merges and this branch is rebased onto master.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants