Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/pages/api/card-media.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Any other props supplied will be provided to the root element (native element).
|:-----|:-------------|:------------|
| <span class="prop-name">root</span> | <span class="prop-name">MuiCardMedia-root</span> | Styles applied to the root element.
| <span class="prop-name">media</span> | <span class="prop-name">MuiCardMedia-media</span> | Styles applied to the root element if `component="video, audio, picture, iframe, or img"`.
| <span class="prop-name">img</span> | <span class="prop-name">MuiCardMedia-img</span> | Styles applied to the root element if `component="picture or img"`.

You can override the style of the component thanks to one of these customization points:

Expand Down
4 changes: 4 additions & 0 deletions packages/material-ui/src/CardMedia/CardMedia.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export const styles = {
/* Styles applied to the root element if `component="video, audio, picture, iframe, or img"`. */
media: {
width: '100%',
},
/* Styles applied to the root element if `component="picture or img"`. */
img: {
// ⚠️ object-fit is not supported by IE 11.
objectFit: 'cover',
},
Expand Down Expand Up @@ -49,6 +52,7 @@ const CardMedia = React.forwardRef(function CardMedia(props, ref) {
classes.root,
{
[classes.media]: isMediaComponent,
[classes.img]: ['picture', 'img'].indexOf(Component) !== -1,
},
className,
)}
Expand Down