Open maeertin opened 2 years ago
Looks like an interesting proposal. However, in order for creating a custom mixin, I would expect you may need more things from the theme (maybe the whole resolved theme actually). My proposal would be doing something like this: https://codesandbox.io/s/sweet-microservice-htiq4r?file=/src/App.tsx
You can also use the proposal from this section - https://mui.com/material-ui/customization/theming/#createtheme-options-args-theme for example using the second arg in createTheme
, although for this scenario that you have the codesandbox example should be enough.
While doing the codesandbox, I noticed that we probably want to export the Mixins
type from @mui/material/styles
directly, so that developers don't need to know our internals.
Hi there :) That's actually what I'm currently doing but only needing breakpoints
& spacing
, but was worth a shot as a proposal. Thanks for the help!
Duplicates
Latest version
Summary 💡
Update https://github.com/mui/material-ui/blob/master/packages/mui-material/src/styles/createMixins.js so that it forwards
createMixins
arguments to the "mixinsInput" if passed as a function tocreateTheme
. Suggestion added above.Examples 🌈
https://github.com/mui/material-ui/blob/4eef029981b08c77a9c52d0b863e6b5ced279087/packages/mui-material/src/styles/createTypography.js#L32
createTypography
is already set up in this this way.Motivation 🔦
For the same reason that the internal mui
createMixins
has access to breakpoints/spacing, I think that theme creators should have the same possibilities when creating custom mixins.For example: