Skip to content

docs: clarify createTheme warning for future compatibility #46476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

satendra03
Copy link

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 cd15701

@zannager zannager added docs Improvements or additions to the documentation customization: theme Centered around the theming features 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customization: theme Centered around the theming features docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants