In my project, I am utilizing the combination of Material UI and React Table. Recently, I was asked to add an expandable row, and I successfully implemented that feature. Once a user expands the row, we display additional table rows based on the data.
If you would like to see a working demo of this implementation, you can visit this link: https://codesandbox.io/s/tanstack-table-expansion-sub-level-goe-191pip?file=/src/styles.css:0-8
To further clarify the requirements, please refer to the attached screenshots (https://i.sstatic.net/UfbnL.jpg and https://i.sstatic.net/TntOx.jpg). The task now is to add border-top and border-bottom styles to the first and last row respectively in the list of expanded rows. Each expanded row has a className of depth-1
, with subsequent deeper expansions labeled as depth-2
.
While I have been able to differentiate the background colors of the expanded rows, applying only the desired border styles proved challenging. I attempted using nth-of-type, as well as first-child and last-child selectors, but encountered difficulties.
I am seeking advice on the feasibility of achieving this task. Is my current approach correct?
Following the guidance provided: