diff --git a/packages/mui-material/src/styles/createTheme.spec.ts b/packages/mui-material/src/styles/createTheme.spec.ts index 6230b912ae7c83..7cccf54140adca 100644 --- a/packages/mui-material/src/styles/createTheme.spec.ts +++ b/packages/mui-material/src/styles/createTheme.spec.ts @@ -210,6 +210,24 @@ const theme = createTheme(); }); } +// props callback in variants +{ + createTheme({ + components: { + MuiButton: { + variants: [ + { + props: (props) => props.color !== 'secondary', + style: ({ theme: { palette } }) => ({ + backgroundColor: palette.grey[500], + }), + }, + ], + }, + }, + }); +} + { createTheme({ shape: { diff --git a/packages/mui-material/src/styles/variants.d.ts b/packages/mui-material/src/styles/variants.d.ts index 8373d35b145fb1..2d35738efc4c96 100644 --- a/packages/mui-material/src/styles/variants.d.ts +++ b/packages/mui-material/src/styles/variants.d.ts @@ -3,7 +3,13 @@ import { ComponentsPropsList } from './props'; export type ComponentsVariants = { [Name in keyof ComponentsPropsList]?: Array<{ - props: Partial; + props: + | Partial + | (( + props: Partial & { + ownerState: Partial; + }, + ) => boolean); style: Interpolation<{ theme: Theme }>; }>; };