Skip to content

Conversation

@satendra03
Copy link
Contributor

@satendra03 satendra03 commented Jul 2, 2025

Closes #46418

What

This PR improves the warning message in the theming documentation related to the usage of createTheme() with multiple arguments.

The original message says:

"Only the first argument (options) is processed by the createTheme() function. If you want to actually merge two themes' options and create a new one based on them, you may want to deep merge the two options and provide them as a first argument to the createTheme() function."

However, in practice, createTheme() currently supports multiple arguments due to internal deep merging, which can confuse developers who observe behavior that contradicts the warning.


Why

The updated warning:

  • Preserves the existing explanation
  • Adds a clarification that the current support for multiple arguments exists for backward compatibility
  • Clearly advises developers to manually deep merge theme objects to ensure future-proof code

This resolves confusion raised in #46418, where users expected the function to reject multiple arguments based on the wording, but observed that it worked in practice.


How

Updated the :::warning block in:
docs/data/material/customization/theming/theming.md

New content explicitly explains:

  • The reason multiple arguments still work
  • That the behavior may be removed in future versions
  • The recommended approach of manual deep merging

Final

Developers will now see a clearer, forward-looking warning that helps them avoid depending on potentially deprecated behavior.


@mui-bot
Copy link

mui-bot commented Jul 2, 2025

Netlify deploy preview

Bundle size report

Bundle Parsed Size Gzip Size
@mui/material 0B(0.00%) 0B(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 1de9be7

@zannager zannager added docs Improvements or additions to the documentation. customization: theme Higher level theming customizability. labels Jul 3, 2025
@zannager zannager requested a review from siriwatknp July 3, 2025 10:08
satendra03 and others added 2 commits July 5, 2025 14:26
Co-authored-by: mapache-salvaje <71297412+mapache-salvaje@users.noreply.github.com>
Signed-off-by: Satendra Kumar Parteti <143379098+satendra03@users.noreply.github.com>
@satendra03
Copy link
Contributor Author

satendra03 commented Jul 10, 2025

Hi @mapache-salvaje @siriwatknp ,
The PR is still open after the requested changes were made and approved, just wanted to check if there's anything else needed!!

@ZeeshanTamboli ZeeshanTamboli changed the title docs: clarify createTheme warning for future compatibility [docs] Clarify createTheme warning for future compatibility Jul 12, 2025
@ZeeshanTamboli ZeeshanTamboli merged commit 3fdcb91 into mui:master Jul 12, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

customization: theme Higher level theming customizability. docs Improvements or additions to the documentation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[docs] createTheme() deep merge unclear warning

6 participants