In the documentation, it states that the 2nd argument of createMuiTheme is an array, however, while working with it, it turns out to be an object which is merged with the final theme object.


Just a suggestion, it would be great if createMuiTheme can take in a function with _default theme_ as the first argument, just for the purpose of re-using certain values or methods.
For Example:
createMuiTheme((theme) => ({
overrides: {
MuiIconButton: {
root: {
borderRadius: "10px",
[theme.breakpoints.down("sm")]: { borderRadius: "0" },
},
},
},
}));
Take a quick look at https://github.com/mui-org/material-ui/issues/21757, guess it's very relevant for you.
Take a quick look at #21757, guess it's very relevant for you.
Yes, it's good to know that the latter part of my query/ issue (suggestion) is already being discussed and taken into consideration, however, can you respond to the former part i.e I think in the documentation for createMuiTheme the second argument should be stated as an object? or not? I'm not sure, maybe I misinterpret it but ...args(Array) is not clear. Please explain.
Thank you for your response.
What about this approach for documenting the prop?
diff --git a/docs/src/pages/customization/theming/theming.md b/docs/src/pages/customization/theming/theming.md
index 745ff19709..6e2955f063 100644
--- a/docs/src/pages/customization/theming/theming.md
+++ b/docs/src/pages/customization/theming/theming.md
@@ -70,7 +70,7 @@ Generate a theme base on the options received.
#### Arguments
1. `options` (_Object_): Takes an incomplete theme object and adds the missing parts.
-2. `...args` (_Array_): Deep merge the arguments with the about to be returned theme.
+2. `...args` (_Object[]_): Deep merge the arguments with the about to be returned theme.
#### Returns
@@ -198,7 +198,7 @@ function Fade() {
#### Arguments
1. `options` (_Object_): Takes an incomplete theme object and adds the missing parts.
-2. `...args` (_Array_): Deep merge the arguments with the about to be returned theme.
+2. `...args` (_Object[]_): Deep merge the arguments with the about to be returned theme.
#### Returns

Otherwise, I wonder if we shouldn't move away from manually authoring these API sections to something automated. We could:
diff --git a/packages/material-ui/src/styles/createMuiTheme.d.ts b/packages/material-ui/src/styles/createMuiTheme.d.ts
index 27b380c35e..41f56122d7 100644
--- a/packages/material-ui/src/styles/createMuiTheme.d.ts
+++ b/packages/material-ui/src/styles/createMuiTheme.d.ts
@@ -44,4 +44,11 @@ export interface Theme {
unstable_strictMode?: boolean;
}
+/**
+ * Generate a theme base on the options received.
+ *
+ * @param options Takes an incomplete theme object and adds the missing parts.
+ * @param {...args} Deep merge the arguments with the about to be returned theme.
+ * @returns A complete, ready to use theme object.
+ */
export default function createMuiTheme(options?: ThemeOptions, ...args: object[]): Theme;

@eps1lon Did you consider this problem in the past?
@eps1lon Did you consider this problem in the past?
I don't think it's worth exploring at the moment since we have so few cases applying. They don't change often enough so hard-coding seems like a better solution.
@oliviertassinari I think the documentation is sufficient on this one.
It's an array of attributes and most, but not all, are objects (e.g. direction is ltr or rtl).
I can take this one if no one else wants it :)