Skip to content

[tabs][toolbar] Reduce bundle size#5221

Merged
atomiks merged 4 commits into
mui:masterfrom
atomiks:claude/base-ui-tabs-toolbar-simplify-1831a3
Jul 13, 2026
Merged

[tabs][toolbar] Reduce bundle size#5221
atomiks merged 4 commits into
mui:masterfrom
atomiks:claude/base-ui-tabs-toolbar-simplify-1831a3

Conversation

@atomiks

@atomiks atomiks commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Removes behavior-neutral dead weight from the Tabs and Toolbar entry points. The bundle bot is authoritative for the current size impact.

Runtime-only enum values are inlined and pinned by enum-sync tests, redundant context members are removed, duplicated lookup and direction logic is consolidated, and the composite substrate's IndexGuessBehavior representation is made tree-shakeable. Tabs, Toolbar, Toggle Group, and composite regressions cover the affected behavior.

@atomiks atomiks added component: tabs Changes related to the tabs component. component: toolbar Changes related to the toolbar component. scope: all components Widespread work has an impact on almost all components. labels Jul 13, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 13, 2026

Copy link
Copy Markdown

commit: f260347

@code-infra-dashboard

code-infra-dashboard Bot commented Jul 13, 2026

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react ▼-1.37KB(-0.30%) ▼-323B(-0.22%)

Details of bundle changes

Performance

Total duration: 1,198.31 ms -165.33 ms(-12.1%) | Renders: 78 (+0) | Paint: 1,870.81 ms -240.25 ms(-11.4%)

Test Duration Renders
Popover mount (300 instances) 58.67 ms ▼-21.16 ms(-26.5%) 1 (+0)
Checkbox mount (500 instances) 57.99 ms ▼-15.36 ms(-20.9%) 1 (+0)
Tooltip mount (300 contained roots) 45.91 ms ▼-13.13 ms(-22.2%) 1 (+0)

11 tests within noise — details


Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Jul 13, 2026

Copy link
Copy Markdown

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit f260347
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a54f91b41f0560008d35f24
😎 Deploy Preview https://deploy-preview-5221--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@atomiks atomiks added performance and removed scope: all components Widespread work has an impact on almost all components. labels Jul 13, 2026
@atomiks
atomiks requested a review from Copilot July 13, 2026 10:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR reduces bundle size in the Tabs and Toolbar entrypoints by removing behavior-neutral indirections (enum/IIFE references, redundant context members) and by consolidating repeated lookup/direction logic, while keeping runtime behavior pinned by existing and new tests.

Changes:

  • Toolbar: simplify separator orientation derivation, remove unused setItemMap from ToolbarRootContext, and rely on downstream defaults for optional props.
  • Tabs: inline data attribute / CSS variable names (with a new test to keep them synced with docs enums), simplify tab activation/highlight wiring, and deduplicate tab element lookup + activation-direction computation.
  • Composite internals: make IndexGuessBehavior tree-shakeable and trim small dead/default code paths.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/react/src/toolbar/separator/ToolbarSeparator.tsx Simplifies derived separator orientation without enum indirection.
packages/react/src/toolbar/root/ToolbarRootContext.ts Removes unused context member to trim toolbar entrypoint weight.
packages/react/src/toolbar/root/ToolbarRoot.tsx Drops redundant context wiring and relies on downstream defaults for optional props.
packages/react/src/toolbar/link/ToolbarLink.test.tsx Updates test context shape after context member removal.
packages/react/src/toolbar/input/ToolbarInput.tsx Makes group context optional and deduplicates disabled-event prevention handlers.
packages/react/src/toolbar/input/ToolbarInput.test.tsx Updates test context shape after context member removal.
packages/react/src/toolbar/group/ToolbarGroupContext.ts Makes group context access always-optional to enable tree-shaking and simpler call sites.
packages/react/src/toolbar/group/ToolbarGroup.test.tsx Updates test context shape after context member removal.
packages/react/src/toolbar/button/ToolbarButton.tsx Makes group context optional and relies on useButton defaults for nativeButton.
packages/react/src/toolbar/button/ToolbarButton.test.tsx Updates test context shape after context member removal.
packages/react/src/toggle-group/ToggleGroup.tsx Makes toolbar group context optional to avoid unnecessary runtime branching.
packages/react/src/tabs/tab/TabsTab.tsx Removes redundant list-context members, uses composite root highlight state, and calls onValueChange directly with guarded activation.
packages/react/src/tabs/root/TabsRootContext.ts Changes panel registration to return an unsubscribe cleanup function.
packages/react/src/tabs/root/TabsRoot.tsx Extracts shared tab lookup helper and consolidates activation-direction logic.
packages/react/src/tabs/root/stateAttributesMapping.ts Inlines the emitted data attribute name for better tree-shaking.
packages/react/src/tabs/panel/TabsPanel.tsx Simplifies panel list item registration and uses cleanup-returning panel registration.
packages/react/src/tabs/list/TabsListContext.ts Removes dead/redundant context members to reduce tabs entrypoint size.
packages/react/src/tabs/list/TabsList.tsx Stops re-exporting activation/highlight plumbing through list context; keeps it inside composite root usage.
packages/react/src/tabs/indicator/TabsIndicator.tsx Inlines CSS variable names and slightly simplifies scale checks used for measurement.
packages/react/src/tabs/enumSync.test.tsx Adds tests to keep docs enums and runtime inlined literals in sync without shipping production bytes.
packages/react/src/internals/composite/root/useCompositeRoot.ts Removes small redundant defaults/returns and simplifies modifier-key iteration.
packages/react/src/internals/composite/list/useCompositeListItem.ts Replaces enum with tree-shakeable const object + type alias for IndexGuessBehavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@atomiks
atomiks marked this pull request as ready for review July 13, 2026 11:01
@atomiks
atomiks force-pushed the claude/base-ui-tabs-toolbar-simplify-1831a3 branch from 3e728a6 to f260347 Compare July 13, 2026 14:41
@atomiks
atomiks merged commit af2aadb into mui:master Jul 13, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: tabs Changes related to the tabs component. component: toolbar Changes related to the toolbar component. performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants