My question is related to having a header in my table that has the style - position: 'sticky'. And that's where all the problems come from. Now more
I set a sticky header to make it easy for the user to scroll through long tables. But the header in the table has rounded edges (top right and top left), and the table itself has a box-shadow. And it turns out that when the user scrolls the table, the box-shadow scrolls along with the table, and space is visible in the gap between the header and the beginning of the table.
Perhaps the description is confusing, here is a video (note the box-shadow and rounded edges of the table)
My header very simple
Header.jsx
import { styles } from "../DataTablesStyles";
export default function Header() {
return (
<TableHead sx={{position: 'sticky',top: '0px',zIndex: '1'}}>
<TableRow >
<TableCell style={styles.TableHeaderStyleFirst}>Actions</TableCell>
<TableCell style={styles.TableHeaderStyle}>Status</TableCell>
<TableCell style={styles.TableHeaderStyle}>Device ID</TableCell>
<TableCell style={styles.TableHeaderStyle}>Model</TableCell>
<TableCell style={styles.TableHeaderStyle}>Operation<br></br>System</TableCell>
<TableCell style={styles.TableHeaderStyle}>Api<br></br>level</TableCell>
<TableCell style={styles.TableHeaderStyle}>Last activity</TableCell>
<TableCell style={styles.TableHeaderStyleLast}></TableCell>
</TableRow>
</TableHead>
);
}
DataTablesStyles.js
// In TableStyle I define the style of the whole table
const TableStyle = {
borderTopRightRadius: '8px',
borderTopLeftRadius: '8px',
alignItems: 'center',
justifyContent: "flex-end",
padding: '16px',
minWidth: '750px',
boxShadow: '0px 0px 10px 0.1px rgba(124, 159, 236, 0.3)',
}
const TableHeaderStyle = {
fontWeight: '400',
fontSize: '14px',
letterSpacing: '0.4px',
color: 'black',
backgroundColor: '#EAECF4',
textAlign: 'center',
padding: '2px',
}
const TableHeaderStyleFirst = {
borderTopLeftRadius: '8px',
fontWeight: '400',
fontSize: '14px',
letterSpacing: '0.4px',
color: 'black',
backgroundColor: '#EAECF4',
textAlign: 'center',
padding: '2px',
}
const TableHeaderStyleLast = {
borderTopRightRadius: '8px',
fontWeight: '400',
fontSize: '14px',
letterSpacing: '0.4px',
color: 'black',
backgroundColor: '#EAECF4',
borderTopRightRadius: '8px',
textAlign: 'center',
padding: '2px',
}
I think you already understand the essence of my question. How to make it so that the shadow does not scroll and the gap is not visible
