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

[docs] Update code snippet in docs for custom color palette #32946

6 changes: 5 additions & 1 deletion packages/mui-material/src/Chip/Chip.js
Expand Up @@ -152,7 +152,11 @@ const ChipRoot = styled('div', {
marginLeft: -4,
}),
...(ownerState.color !== 'default' && {
color: alpha(theme.palette[ownerState.color].contrastText, 0.7),
color: alpha(
ZeeshanTamboli marked this conversation as resolved.
Show resolved Hide resolved
theme.palette[ownerState.color].contrastText ||
theme.palette.getContrastText(theme.palette[ownerState.color].main),
0.7,
),
'&:hover, &:active': {
color: theme.palette[ownerState.color].contrastText,
},
Expand Down
18 changes: 18 additions & 0 deletions packages/mui-material/src/Chip/Chip.test.js
Expand Up @@ -616,4 +616,22 @@ describe('<Chip />', () => {
expect(chip).not.to.have.class(classes.focusVisible);
});
});

it('should not throw error when a new palette color is added in theme', () => {
const theme = createTheme({
palette: {
custom: {
main: '#f90',
},
},
});

expect(() =>
render(
<ThemeProvider theme={theme}>
<Chip color="custom" label="A test" />
</ThemeProvider>,
),
).not.to.throw();
});
});