Skip to content

[button] Remove duplicated className entries#48213

Draft
silviuaavram wants to merge 1 commit intomui:masterfrom
silviuaavram:fix/duplicated-button-classnames
Draft

[button] Remove duplicated className entries#48213
silviuaavram wants to merge 1 commit intomui:masterfrom
silviuaavram:fix/duplicated-button-classnames

Conversation

@silviuaavram
Copy link
Copy Markdown
Member

@silviuaavram silviuaavram commented Apr 6, 2026

Fixes #48189.

Button is sending both className and classes to ButtonRoot.

@silviuaavram silviuaavram self-assigned this Apr 6, 2026
Copilot AI review requested due to automatic review settings April 6, 2026 15:31
@silviuaavram silviuaavram added type: bug It doesn't behave as expected. scope: button Changes related to the button. labels Apr 6, 2026
@silviuaavram silviuaavram marked this pull request as draft April 6, 2026 15:31
@mui-bot
Copy link
Copy Markdown

mui-bot commented Apr 6, 2026

Netlify deploy preview

https://deploy-preview-48213--material-ui.netlify.app/

Bundle size report

Bundle Parsed size Gzip size
@mui/material ▼-7B(0.00%) ▼-4B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against 2f58e1d

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 fixes duplicated CSS class entries on the Material UI Button root element by avoiding passing the same utility classes through both className and the classes prop path (via ButtonBase).

Changes:

  • Remove classes.root from the className passed to ButtonRoot, relying on the existing classes={classes} forwarding to apply utility classes once.

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

Copy link
Copy Markdown
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

I think we should omit classes.root when we propagate the classes prop instead. We should do that on all components using ButtonBase.

What I meant was doing this:

    <ButtonRoot
      ownerState={ownerState}
      className={clsx(contextProps.className, className, classes.root, positionClassName)}
      component={component}
      disabled={disabled || loading}
      focusRipple={!disableFocusRipple}
      focusVisibleClassName={clsx(classes.focusVisible, focusVisibleClassName)}
      ref={ref}
      internalNativeButton
      type={type}
      id={loading ? loadingId : idProp}
      {...other}
      // classes.root is already propagated in the className prop
      classes={{...classes, root: {}}}
    >

@ZeeshanTamboli
Copy link
Copy Markdown
Member

I guess it's a regression since #25072. The issue is also present in v5: https://v5.mui.com/material-ui/react-button/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: button Changes related to the button. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Button] Duplicate classes

5 participants