Skip to content

Arbitrary scaling of the MUI default theme #45882

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
pingnikhil opened this issue Apr 11, 2025 · 3 comments
Open

Arbitrary scaling of the MUI default theme #45882

pingnikhil opened this issue Apr 11, 2025 · 3 comments
Assignees
Labels
customization: theme Centered around the theming features docs Improvements or additions to the documentation

Comments

@pingnikhil
Copy link

pingnikhil commented Apr 11, 2025

Hi,

My application needs a highly compact, almost a miniaturized version of the default MUI theme.

I've read the customization/theming sections of the official MUI docs a few times already but it still isn't clear what the minimum set of styles along with their values is that the new theme must include or override so that it can uniformly scale all components and their subcomponents down (or even up, if needed!) by an arbitrary scaling factor, 'S'.

Because most components are composed of subcomponents, the scaled theme should also appropriately reposition (and adjust all aspects of) the latter as a function of S, as also e.g. any and all margins and paddings (or, gaps in case of flex containers).

For example, when a TextField is scaled down, its input labels, helper text etc would need not only scaling but also a little repositioning to preserve an aspect of the aesthetics offered in the MUI default theme.

Would greatly appreciate if someone could:

  1. Either make available a parameterized version of the default theme that covers all MUI and MUI X components;

  2. Or share complete and detailed guidance on how to do this oneself -- for all components and subcomponents -- especially, if one isn't familiar with the internals of all MUI/X components!

Regards,
NS

Order ID: 111292

Search keywords:

@github-actions github-actions bot added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Apr 11, 2025
@zannager zannager added the customization: theme Centered around the theming features label Apr 11, 2025
@siriwatknp siriwatknp added docs Improvements or additions to the documentation and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Apr 14, 2025
@siriwatknp
Copy link
Member

I'll create an experiment page and share with you.

@pingnikhil
Copy link
Author

@siriwatknp May I ask when will this experiement page be ready by?
Also, does "experiment" page mean that it won't be the final solution?

Regards,
NS

@siriwatknp
Copy link
Member

siriwatknp commented Apr 24, 2025

@siriwatknp May I ask when will this experiement page be ready by?
Also, does "experiment" page mean that it won't be the final solution?

At the moment, there is no global config that will flip all components to miniature size. However, some components have size prop that you can set to the lowest value as default using theme.

@pingnikhil The first step is to follow the density docs to make the default components into small size.

For the rest of the component, it has to be configured to the theme one-by-one through theme.styleOverrides:

createTheme({
  components: {
    MuiAccordion: {
      styleOverrides: {}
    }
  }
})

Next step, if you need smaller size than small, here is the example of adding mini size to the Button: https://stackblitz.com/edit/react-xcut7zwl?file=Demo.tsx

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

No branches or pull requests

3 participants