Skip to content

[material-ui] className and style from theme default props are not merged with the component slotProps #45919

Open
@siriwatknp

Description

@siriwatknp

Issue

If the theme defaultProps.slotProps defines className and style, they are replaced by the component's slotProps:

// src/theme.ts
const theme = createTheme({
  components: {
    MuiCardHeader: {
      defaultProps: {
        slotProps: {
          title: {
            className: "text-sm",
            style: {
              color: "red",
            },
          },
        },
      },
    },
  },
});

<ThemeProvider theme={theme}>
  <CardHeader
    slotProps={{
      title: { className: 'text-red-500', style: { background: 'blue' } },
    }}
  />
</ThemeProvider>

The className and style from the theme are replaced by the slotProps on the component instance.

Expected

Based on the above snippet, the CardHeader should have className text-sm text-red-500 and the style color: 'red', background: 'blue'.

Use case

When using Material UI together and Tailwind CSS together.

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions