ui icon indicating copy to clipboard operation
ui copied to clipboard

Checkboxes ui styling error on data tables

Open Pawel1894 opened this issue 2 years ago • 14 comments

Hey,

I was exploring yours docs and found a bit strange behaviour on data tables, when selecting row. When row is selected checkbox is higher than unchecked, thought you might look into that it can scare away some devs I guess.

Selected row: obraz

Unselected row: obraz

Link to example: https://ui.shadcn.com/docs/components/data-table

Pawel1894 avatar Jun 01 '23 08:06 Pawel1894

I fixed this by adding "display: inline-flex;" / tailwind "inline-flex" to the checkbox component

nicoknoll avatar Jun 27 '23 14:06 nicoknoll

Also worth mentioning that this happens in Firefox (at least for me). In chrome it looks fine

nicoknoll avatar Jun 27 '23 14:06 nicoknoll

Same here, display: inline-flex also fixes the thing on Firefox

nugmanoff avatar Jun 29 '23 15:06 nugmanoff

inline-flex actually isn't perfect either, the checkbox icon inside is then nudged too far right and/or enlarged. The whole component also still sitting with the bottom edge on the baseline rather than hanging slightly below it when it is checked. And toggling between checked and unchecked you can see the row changing height by 1 pixel.

image

I don't have good enough CSS chops to figure out the fix I think (I have tried) but I'd like it if there was a proper update on this.

marten avatar Sep 07 '23 15:09 marten

Hello there. I'm also experiencing the same issue. I also noticed that when selected, not only does the check box move up, the row also increases in height by 0.8 pixels. inline-flex does indeed fix the check box moving issue, but the row still gets taller, and as said in the post above, the check is misaligned.

infiniwave avatar Sep 11 '23 14:09 infiniwave

It seems like the amount the row height enlarges is proportional to the window size.

infiniwave avatar Sep 11 '23 14:09 infiniwave

I just had this issue with the row size increasing. I could fix it by changing the following in the Checkbox component:

<Check className="h-4 w-4" /> to <Check className="h-3.5 w-3.5" />. Haven't checked if this is a solution in general yet, but in my case it worked. But I'll try to take a look.

iamtburger avatar Sep 22 '23 21:09 iamtburger

With display inline-flex still padding botton when is selected =/

IgorDePaula avatar Oct 17 '23 13:10 IgorDePaula

In both: firefox and chrome.

IgorDePaula avatar Oct 17 '23 13:10 IgorDePaula

You must join inline-flex with mt-2

IgorDePaula avatar Oct 17 '23 14:10 IgorDePaula

I fixed this by adding an absolute to the indicator parent component. That might not work for your (other) use cases for a variety of probably obvious reasons.

checkbox-stable

gburtini avatar Jan 15 '24 04:01 gburtini

[@supports(-moz-appearance:none){&>[role=checkbox]}]:inline-flex [@supports(-moz-appearance:none){&>[role=checkbox]}]:justify-center

Currently, im using firefox and get that problem but on chorme and edge is fine. So my solution is add this class into TableHead and TableCell. It should be work propertly.

lil-liamtr avatar Jan 18 '24 09:01 lil-liamtr

The solution from @n3mooo works perfectly for me.

sangdth avatar Feb 03 '24 08:02 sangdth

I followed @n3mooo's suggestion. For me it went like this:

TableHead: [&:has([role=checkbox])]:inline-flex [&:has([role=checkbox])]:items-center

TableCell: [&:has([role=checkbox])]:inline-flex [&:has([role=checkbox])]:items-center h-16

nuclei272 avatar May 18 '24 00:05 nuclei272

This issue has been automatically closed because it received no activity for a while. If you think it was closed by accident, please leave a comment. Thank you.

shadcn avatar Jun 30 '24 23:06 shadcn