Prop | Type | Default | Description |
---|---|---|---|
children | node | The content of the table, normally TableHead and TableBody. | |
classes | object | Override or extend the styles applied to the component. See CSS API below for more details. | |
component | elementType | 'table' | The component used for the root node. Either a string to use a HTML element or a component. |
padding | 'default' | 'checkbox' | 'none' | 'default' | Allows TableCells to inherit padding of the Table. |
size | 'small' | 'medium' | 'medium' | Allows TableCells to inherit size of the Table. |
stickyHeader | bool | false | Set the header sticky. ⚠️ It doesn't work with IE 11. |
() => {function createData(name, calories, fat, carbs, protein) {return { name, calories, fat, carbs, protein };}const rows = [createData('Frozen yoghurt', 159, 6.0, 24, 4.0),createData('Ice cream sandwich', 237, 9.0, 37, 4.3),createData('Eclair', 262, 16.0, 24, 6.0),createData('Cupcake', 305, 3.7, 67, 4.3),createData('Gingerbread', 356, 16.0, 49, 3.9),];return (<TableContainer component={Paper}><Table aria-label="simple table"><TableHead><TableRow><TableCell>Dessert (100g serving)</TableCell><TableCell align="right">Calories</TableCell><TableCell align="right">Fat(g)</TableCell><TableCell align="right">Carbs(g)</TableCell><TableCell align="right">Protein(g)</TableCell></TableRow></TableHead><TableBody>{rows.map((row) => (<TableRow key={row.name}><TableCell component="th" scope="row">{row.name}</TableCell><TableCell align="right">{row.calories}</TableCell><TableCell align="right">{row.fat}</TableCell><TableCell align="right">{row.carbs}</TableCell><TableCell align="right">{row.protein}</TableCell></TableRow>))}</TableBody></Table></TableContainer>);};
This example is quite long so if you have a use case for this please see Material UI's example