Skip to content
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

[Alert] Add paper Slot Support in MuiAlert Component for Styling Customization #44819

Open
LeahMaier opened this issue Dec 20, 2024 · 1 comment
Assignees
Labels
component: alert This is the name of the generic UI component, not the React module! status: waiting for maintainer These issues haven't been looked at yet by a maintainer

Comments

@LeahMaier
Copy link

LeahMaier commented Dec 20, 2024

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

@LeahMaier LeahMaier added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 20, 2024
@mnajdova
Copy link
Member

We are consolidating the slots and slotProps API right now, so we will look into this. @siriwatknp can likely provide more info/timeline on when this would be available.

@aarongarciah aarongarciah changed the title [alert] Add paper Slot Support in MuiAlert Component for Styling Customization [Alert] Add paper Slot Support in MuiAlert Component for Styling Customization Dec 24, 2024
@aarongarciah aarongarciah added the component: alert This is the name of the generic UI component, not the React module! label Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: alert This is the name of the generic UI component, not the React module! status: waiting for maintainer These issues haven't been looked at yet by a maintainer
Projects
None yet
Development

No branches or pull requests

4 participants