I'm trying to set a max-width for the cells that are part of a column of a material table, like you can do with Fluent UI's tables.
The table needs to have width: 100% and the cells need to be able to be smaller than the max-width.
After setting max-width to both the cells and their children, the cells still stretch to a greater width than the limit that was set, although less than it would otherwise.
I did manage to set a fixed width, however, although border-box doesn't seem to work with it, for some reason.
Is there a way to set a max-width to a column without limiting the size of the table or setting a fixed width?
Relevant sections:
const width = 100;
const style = {
maxWidth: width,
borderStyle: "border-box"
};
// inside head row
<TableCell align="right" sx={style}>
<div style={style}>Protein (g)</div>
</TableCell>
// inside table row loop
<TableCell align="right" sx={style}>
<div style={style}>{row.protein}</div>
</TableCell>