Skip to content

Merging functional slotProps of a theme #48907

Closed

Description

@GerardasB

Steps to reproduce

Steps:

  1. Open this link to live example: https://stackblitz.com/edit/github-nxqwy3jw?file=src%2FApp.tsx
  2. Click the "Dashboard" button
  3. Observe that the aria-labelledby attribute is not set on the list of a Menu component (element with role="menu".

Additionally, you can uncomment the lines that set the slotProps of the list as an object (in the theme) and observe that both the aria-labelledby of the theme and className of the component are merged.

Current behavior

The functional slotProps prop behaves differently than the object variant when set via the defaultProps of a theme.

When the object is used, the slotProps set on the component are merged with the slotProps of the theme. However, the function(al) slotProps of the theme is overridden entirely if the slotProps is set on the component.

This behavior is not ideal, as theme level customizations might be overridden unintentionally and pushes the theme customization towards the slots prop (when the ownerState is needed) - which is not ideal either, as it overrides MUI's default slots (usually just styling, but might include other functionality or internal components).

Expected behavior

(returned) Functional slotProps set via the defaultProps of a theme should be merged with slotProps set via the component.

Context

Working on a theme that customizes both the styling and semantics of MUI components - the ownerState is helpful to get the props passed in the component (or internal component state).

Your environment

No response

Search keywords: slotProps merging theme functional

Activity

  1. added
    status: waiting for maintainer
    on Aug 3, 2026
  2. added
    scope: menu
    customization: theme
    on Aug 3, 2026
  3. added
    not planned
    and removed
    status: waiting for maintainer
    on Aug 4, 2026
  4. silviuaavram commented on Aug 4, 2026

    @silviuaavram
    Member

    The usage is quite strange, since you're using the theme for non-theme use case. Not going to address, feel free to wrap the Menu and change it accordingly if you need it.

  5. GerardasB commented on Aug 4, 2026

    @GerardasB
    ContributorAuthor

    Why is this deemed a non-theme use-case? The theme allows customizing default props of a component or it's slots. There are two ways to customize slots: object or a function, I'm simply using the function.

    EDIT: in our case we are trying to avoid wrapper components.

  6. mnajdova commented on Aug 12, 2026

    @mnajdova
    Member

    I would consider this a bug. Why:

    1. We are already doing deep merge when slotProps are objects
    2. Considering the above, it makes sense to work the same way when those are defined as functions
    3. It wasn't intentional decision - none of the past PR handled this and it was never documented as expected behavior.

    PR created - #48955

  7. added
    type: bug
    and removed
    not planned
    on Aug 12, 2026
  8. github-actions commented on Aug 18, 2026

    @github-actions
    Contributor

    This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
    Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.


    @GerardasB Thanks again for creating this issue! If you have a moment, we would love to hear your thoughts on how we handled it with this short feedback form.

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

Metadata

Metadata

Assignees

Labels

customization: themescope: menutype: bug

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions