Files
react-test/docs/data/joy/components/table/TableScrollingShadows.js
how2ice 005cf56baf
Some checks failed
No response / noResponse (push) Has been cancelled
CI / Continuous releases (push) Has been cancelled
CI / test-dev (macos-latest) (push) Has been cancelled
CI / test-dev (ubuntu-latest) (push) Has been cancelled
CI / test-dev (windows-latest) (push) Has been cancelled
Maintenance / main (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
init project
2025-12-12 14:26:25 +09:00

82 lines
2.6 KiB
JavaScript

import Table from '@mui/joy/Table';
import Typography from '@mui/joy/Typography';
import Sheet from '@mui/joy/Sheet';
function createData(name, calories, fat, carbs, protein) {
return { name, calories, fat, carbs, protein };
}
const rows = [
createData('1', 159, 6.0, 24, 4.0),
createData('2', 237, 9.0, 37, 4.3),
createData('3', 262, 16.0, 24, 6.0),
createData('4', 305, 3.7, 67, 4.3),
createData('5', 356, 16.0, 49, 3.9),
createData('6', 159, 6.0, 24, 4.0),
createData('7', 237, 9.0, 37, 4.3),
createData('8', 262, 16.0, 24, 6.0),
createData('9', 305, 3.7, 67, 4.3),
createData('10', 356, 16.0, 49, 3.9),
];
export default function TableScrollingShadows() {
return (
<div>
<Typography level="body-sm" sx={{ textAlign: 'center', mb: 2 }}>
The table body is scrollable.
</Typography>
<Sheet
sx={(theme) => ({
'--TableCell-height': '40px',
// the number is the amount of the header rows.
'--TableHeader-height': 'calc(1 * var(--TableCell-height))',
height: 200,
overflow: 'auto',
background: `linear-gradient(${theme.vars.palette.background.surface} 30%, rgba(255, 255, 255, 0)),
linear-gradient(rgba(255, 255, 255, 0), ${theme.vars.palette.background.surface} 70%) 0 100%,
radial-gradient(
farthest-side at 50% 0,
rgba(0, 0, 0, 0.12),
rgba(0, 0, 0, 0)
),
radial-gradient(
farthest-side at 50% 100%,
rgba(0, 0, 0, 0.12),
rgba(0, 0, 0, 0)
)
0 100%`,
backgroundSize: '100% 40px, 100% 40px, 100% 14px, 100% 14px',
backgroundRepeat: 'no-repeat',
backgroundAttachment: 'local, local, scroll, scroll',
backgroundPosition:
'0 var(--TableHeader-height), 0 100%, 0 var(--TableHeader-height), 0 100%',
backgroundColor: 'background.surface',
})}
>
<Table stickyHeader>
<thead>
<tr>
<th>Row</th>
<th>Calories</th>
<th>Fat&nbsp;(g)</th>
<th>Carbs&nbsp;(g)</th>
<th>Protein&nbsp;(g)</th>
</tr>
</thead>
<tbody>
{rows.map((row) => (
<tr key={row.name}>
<td>{row.name}</td>
<td>{row.calories}</td>
<td>{row.fat}</td>
<td>{row.carbs}</td>
<td>{row.protein}</td>
</tr>
))}
</tbody>
</Table>
</Sheet>
</div>
);
}