I would like to add space between TableRow MaterialUI ponents. How can I acplish that?
<S.MainTable>
<TableBody>
{rows.map(row => {
return (
<S.StyledTableRow key={row.id}>
<TableCell ponent="th" scope="row">{row.name}</TableCell>
<TableCell numeric>{row.calories}</TableCell>
<TableCell numeric>{row.fat}</TableCell>
<TableCell numeric>{row.carbs}</TableCell>
<TableCell numeric>{row.protein}</TableCell>
</S.StyledTableRow>
);
})}
</TableBody>
</S.MainTable>
I would like to add space between TableRow MaterialUI ponents. How can I acplish that?
<S.MainTable>
<TableBody>
{rows.map(row => {
return (
<S.StyledTableRow key={row.id}>
<TableCell ponent="th" scope="row">{row.name}</TableCell>
<TableCell numeric>{row.calories}</TableCell>
<TableCell numeric>{row.fat}</TableCell>
<TableCell numeric>{row.carbs}</TableCell>
<TableCell numeric>{row.protein}</TableCell>
</S.StyledTableRow>
);
})}
</TableBody>
</S.MainTable>
Share
Improve this question
edited Aug 18, 2018 at 20:36
Abraham
9,9056 gold badges56 silver badges58 bronze badges
asked Aug 18, 2018 at 14:38
Евгений КарповичЕвгений Карпович
511 silver badge2 bronze badges
3 Answers
Reset to default 6Add these few lines of code to your table's CSS:
{
border-spacing: 0 5px !important;
border-collapse: separate !important;
}
you can add spaces between the row of the table by defining paddingBottom and paddingTop in the just like that
<TableCell style={{ paddingBottom: 10, paddingTop: 10 }} colSpan={2}>
<Collapse in={open} timeout="auto" unmountOnExit>
<Box margin={1}>
<Typography variant="h6" gutterBottom ponent="div">
ENGAGEMENT HISTORY
</Typography>
<Table size="small" aria-label="purchases">
<TableHead>
<TableRow>
<TableCell>Date</TableCell>
<TableCell>Club</TableCell>
<TableCell align="right">Staff</TableCell>
</TableRow>
</TableHead>
<TableBody>
{row.engagementHistory.map((historyRow) => (
<TableRow key={historyRow.date}>
<TableCell ponent="th" scope="row">
{historyRow.date}
</TableCell>
<TableCell>{historyRow.contact}</TableCell>
<TableCell align="right">{historyRow.staff}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</Box>
</Collapse>
</TableCell>
Did you used "break" tag? or u can also do with margin and padding .