I want to make a component as in the photo. Is there a difference in using a paper/card, if I don't need an card API, or using paper in this case "violates the semantics of material-ui"?
Asked
Active
Viewed 8,466 times
1 Answers
1
Paper component is mostly background of an application resembles the flat, opaque texture of a sheet of paper, and an application’s behavior mimics paper’s ability to be re-sized, shuffled, and bound together in multiple sheets.
The Card is are surfaces that display content and actions on a single topic.
So for you you should use a Card !
Like this :
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Card from '@material-ui/core/Card';
import CardActionArea from '@material-ui/core/CardActionArea';
import CardActions from '@material-ui/core/CardActions';
import CardContent from '@material-ui/core/CardContent';
import CardMedia from '@material-ui/core/CardMedia';
import Button from '@material-ui/core/Button';
import Typography from '@material-ui/core/Typography';
const useStyles = makeStyles({
root: {
maxWidth: 345,
},
media: {
height: 140,
},
});
export default function MediaCard() {
const classes = useStyles();
return (
<Card className={classes.root}>
<CardActionArea>
<CardMedia
className={classes.media}
image="/static/images/cards/contemplative-reptile.jpg"
title="Contemplative Reptile"
/>
<CardContent>
<Typography gutterBottom variant="h5" component="h2">
Lizard
</Typography>
<Typography variant="body2" color="textSecondary" component="p">
Lizards are a widespread group of squamate reptiles, with over 6,000 species, ranging
across all continents except Antarctica
</Typography>
</CardContent>
</CardActionArea>
<CardActions>
<Button size="small" color="primary">
Share
</Button>
<Button size="small" color="primary">
Learn More
</Button>
</CardActions>
</Card>
);
}

BackSlashHaine
- 119
- 8
-
Can you put a Card on a Paper? – Quang Van Jun 29 '21 at 05:07
-
Because you have a library who handle already this so why do something already there ? Make the diff between a Paper and a Card first those two are not the same and not built for the same use cases. @ankush981 – BackSlashHaine Oct 18 '21 at 10:27