Open
Description
Summary
Currently, the MuiAlert
component does not support the paper
slot for direct styling customization int the theme file. Other MUI components, such as MuiAutocomplete
, use the slotProps
API to allow passing specific props to subcomponents like paper
. Adding support for this in MuiAlert
would simplify the application of custom Paper
variants and other styles directly to the alert’s underlying Paper
element.
Examples
MuiAlert: {
defaultProps: {
slotProps: {
paper: {
variant: 'overlay', // Apply the overlay variant directly to the paper slot
},
},
},
styleOverrides: {
// Default styles for MuiAlert can still be used
},
}
Motivation
- Simplified Styling: Currently, developers need to override
styleOverrides
to apply specific styles such as customPaper
variants. Introducing thepaper
slot would allow this styling to be applied more easily through theslotProps
API, similar to other components likeMuiAutocomplete
. This would streamline styling customization and reduce the need for manual overrides. - Consistency with Other Components: Other components in MUI, such as
MuiAutocomplete
, support theslotProps
API to customize internal elements (e.g.,paper
). Adding this capability toMuiAlert
would align the API across different MUI components, enhancing consistency and developer experience. - Improved Maintainability: By allowing developers to pass props directly to the
paper
element (e.g.,variant
: 'overlay'), this approach reduces the need for duplicate code and manual style overrides, making the codebase easier to maintain and less prone to errors.
Search keywords: alert, slot, defaultProps, paper variant