Cards
Cards contain content and actions about a single subject.
Cards should be easy to scan for relevant and actionable information. Elements, like text and images, should be placed within them in a way that clearly indicates hierarchy.
Basic Card
Variants
Remove elevation and replace with a simple border using variant="outlined"
. You can also remove border-radius
with the boolean prop square
.
Media Card
By default, we use the combination of a div
element and a background image to display the media, resulting in needing to define height or width (depending on card orientation).
If you want to display a video or a responsive image, set the component
property for these use cases.
If the component prop is defined as an 'img', the image will take up the full width of the card (or card-internal container), and adopt a proportionate height. This potentially will result in a stretched image, or — if multiple cards are in use — variance in image height if not using a pre-constrained image size.
We recommend that you either:
- Set the image constraints application-wide so that the
CardMedia
component can have an explicitly set height; or - Set the
CardMedia
component toimg
and enforce a consistent image size or ratio.
These settings reduce variability.
Complex Interaction
Customized Card Layout
Here is a media card leveraging Grid to create a custom layout.
Customized Clickable Layout
This example also shows how to use the CardActionArea
component to enable the entire card surface as clickable. Screen readers will read all display and image alternative text, so keep the content brief inside CardActionArea
. Use CardActionArea
sparingly, reserving for cases when the intent of the card as a clickable element is clear from context in the layout.
Note: Implementation will require an onClick
function to define the action for CardActionArea
to take.