How would you implement a table with custom cells that has a different styling on select #4394
-
Let's say you make a Table component like this - https://codesandbox.io/s/objective-cherry-g837on?file=/src/App.tsx or something like how NextUI does. You render the body part of the table like this -
But if you want to render a custom cell here, how do you handle styling them based on whether they are selected or not? I don't know why I can't figure out something so simple |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Rows have selection, not cells, so you'll notice in that example in let isSelected = state.selectionManager.isSelected(item.key); If you do need the row's selection state inside the cell, in
If you want the selection state outside the component, you should make the table's selection controlled, then you'll be able to access it outside. |
Beta Was this translation helpful? Give feedback.
Maybe have a look at our examples. I think this line will answer your question https://github.com/adobe/react-spectrum/blob/main/examples/rac-tailwind/src/App.js#L561