diff --git a/docs/pages/api/chip.md b/docs/pages/api/chip.md index aa54dce41b3cea..61575f159a1ae4 100644 --- a/docs/pages/api/chip.md +++ b/docs/pages/api/chip.md @@ -64,7 +64,7 @@ Any other props supplied will be provided to the root element (native element). | outlinedPrimary | .MuiChip-outlinedPrimary | Styles applied to the root element if `variant="outlined"` and `color="primary"`. | outlinedSecondary | .MuiChip-outlinedSecondary | Styles applied to the root element if `variant="outlined"` and `color="secondary"`. | avatar | .MuiChip-avatar | Styles applied to the `avatar` element. -| avatarSmall | .MuiChip-avatarSmall | +| avatarSmall | .MuiChip-avatarSmall | Styles applied to the `avatar` element if `size="small"`. | avatarColorPrimary | .MuiChip-avatarColorPrimary | Styles applied to the `avatar` element if `color="primary"`. | avatarColorSecondary | .MuiChip-avatarColorSecondary | Styles applied to the `avatar` element if `color="secondary"`. | icon | .MuiChip-icon | Styles applied to the `icon` element. diff --git a/packages/material-ui/src/Chip/Chip.js b/packages/material-ui/src/Chip/Chip.js index 2de737e3c6f3fb..294e2de2597703 100644 --- a/packages/material-ui/src/Chip/Chip.js +++ b/packages/material-ui/src/Chip/Chip.js @@ -8,7 +8,6 @@ import useForkRef from '../utils/useForkRef'; import unsupportedProp from '../utils/unsupportedProp'; import capitalize from '../utils/capitalize'; import ButtonBase from '../ButtonBase'; -import '../Avatar'; // So we don't have any override priority issue. export const styles = theme => { const backgroundColor = @@ -42,6 +41,29 @@ export const styles = theme => { opacity: 0.5, pointerEvents: 'none', }, + '& $avatar': { + marginLeft: 5, + marginRight: -6, + width: 24, + height: 24, + color: theme.palette.type === 'light' ? theme.palette.grey[700] : theme.palette.grey[300], + fontSize: theme.typography.pxToRem(12), + }, + '& $avatarColorPrimary': { + color: theme.palette.primary.contrastText, + backgroundColor: theme.palette.primary.dark, + }, + '& $avatarColorSecondary': { + color: theme.palette.secondary.contrastText, + backgroundColor: theme.palette.secondary.dark, + }, + '& $avatarSmall': { + marginLeft: 4, + marginRight: -4, + width: 18, + height: 18, + fontSize: theme.typography.pxToRem(10), + }, }, /* Styles applied to the root element if `size="small"`. */ sizeSmall: { @@ -145,32 +167,15 @@ export const styles = theme => { backgroundColor: fade(theme.palette.secondary.main, theme.palette.action.hoverOpacity), }, }, + // TODO remove in V5 /* Styles applied to the `avatar` element. */ - avatar: { - marginLeft: 5, - marginRight: -6, - width: 24, - height: 24, - color: theme.palette.type === 'light' ? theme.palette.grey[700] : theme.palette.grey[300], - fontSize: theme.typography.pxToRem(12), - }, - avatarSmall: { - marginLeft: 4, - marginRight: -4, - width: 18, - height: 18, - fontSize: theme.typography.pxToRem(10), - }, + avatar: {}, + /* Styles applied to the `avatar` element if `size="small"`. */ + avatarSmall: {}, /* Styles applied to the `avatar` element if `color="primary"`. */ - avatarColorPrimary: { - color: theme.palette.primary.contrastText, - backgroundColor: theme.palette.primary.dark, - }, + avatarColorPrimary: {}, /* Styles applied to the `avatar` element if `color="secondary"`. */ - avatarColorSecondary: { - color: theme.palette.secondary.contrastText, - backgroundColor: theme.palette.secondary.dark, - }, + avatarColorSecondary: {}, /* Styles applied to the `icon` element. */ icon: { color: theme.palette.type === 'light' ? theme.palette.grey[700] : theme.palette.grey[300],