Reputation: 51
I would like to add space between TableRow MaterialUI components. How can I accomplish that?
<S.MainTable>
<TableBody>
{rows.map(row => {
return (
<S.StyledTableRow key={row.id}>
<TableCell component="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>
Upvotes: 5
Views: 6406
Reputation: 146
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 component="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 component="th" scope="row">
{historyRow.date}
</TableCell>
<TableCell>{historyRow.contact}</TableCell>
<TableCell align="right">{historyRow.staff}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</Box>
</Collapse>
</TableCell>
Upvotes: -1
Reputation: 101
Add these few lines of code to your table's CSS:
{
border-spacing: 0 5px !important;
border-collapse: separate !important;
}
Upvotes: 6
Reputation: 11
Did you used "break" tag? or u can also do with margin and padding .
Upvotes: -2