Allow use styleOverrides
to target parts in new component variants
#34715
Labels
customization: dom
Component's DOM customizability, e.g. slot
customization: theme
Centered around the theming features
enhancement
This is not a bug, nor a new feature
package: system
Specific to @mui/system
Duplicates
Latest version
Summary 💡
Allow use of
styleOverrides
in custom variants so we can target and theme component parts (e.g.root
,listbox
) that are not accessible by specificity from root.Examples 🌈
Global component overrides can theme component parts via
styleOverrides
.However, when creating new component variants you are put into
root
.The current workaround is to use the global style overrides syntax with
styleOverrides
and a callback withownerState
. This results in variant logic in two syntaxes and spread outside the variants array.I propose we allow the use of the
styleOverrides
syntax with custom variants.styleOverrides
syntaxMotivation 🔦
MuiAutocomplete
uses several parts by portal that are inaccessible via CSS specificity from the root component. By allowing the use ofstyleOverrides
in the new component variants we can target and theme those parts just as we do in global style overrides. This avoids putting variant logic in callbacks outside of the variants array.The text was updated successfully, but these errors were encountered: