Skip to content

[docs][Alert] Missing root slot for style customization #44819

Open
@LeahMaier

Description

@LeahMaier

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

  1. Simplified Styling: Currently, developers need to override styleOverrides to apply specific styles such as custom Paper variants. Introducing the paper slot would allow this styling to be applied more easily through the slotProps API, similar to other components like MuiAutocomplete. This would streamline styling customization and reduce the need for manual overrides.
  2. Consistency with Other Components: Other components in MUI, such as MuiAutocomplete, support the slotProps API to customize internal elements (e.g., paper). Adding this capability to MuiAlert would align the API across different MUI components, enhancing consistency and developer experience.
  3. 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

Metadata

Metadata

Assignees

Labels

component: alertThis is the name of the generic UI component, not the React module!docsImprovements or additions to the documentation

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions