shadcn.io is not affiliated with official shadcn/ui
Checkbox examples · Standard
Horizontal List Checkbox for React
A row of weekday checkboxes that wraps onto a new line when space runs out.
Short options waste space stacked one per line. Here five weekdays flow along a row with flex flex-wrap gap-4, each a horizontal Field with its checkbox and label, and they wrap onto a second line when the container is too narrow. The days are a static list mapped to fields. Use it for compact sets with short labels: weekdays, sizes, time slots.
Preview
Installation
FAQ
When should I use horizontal vs vertical checkbox lists?
Horizontal suits a handful of options with one-word labels, like these five weekdays. Stack the fields in a FieldGroup when the list is longer or the labels wrap inside the row.
How does flex-wrap handle different screen sizes?
The row puts as many days on a line as fit and moves the rest to the next, with no breakpoints. gap-4 keeps the same spacing across and between lines. Each field is w-fit, so it's as wide as its label rather than the full row.
How do I center or right-align horizontal checkbox lists?
Add justify-center or justify-end to the row; every wrapped line aligns the same way. justify-end follows the reading direction, so it puts the days on the left in a right-to-left page.
Should horizontal lists stay horizontal on mobile?
For short labels like these, yes: wrapping handles narrow screens. For longer labels, stack them on small screens with flex-col sm:flex-row. If people mis-tap neighbors, give the row more gap or go vertical.
Related
- Vertical List CheckboxA stacked list of programming language
- Right-Aligned CheckboxA list of notification settings with each
- Nested List CheckboxA select-all checkbox over three indented
- Simple CheckboxA checkbox with a label for a single
- Horizontal Radio GroupA radio group with its three options in a
- Default Toggle GroupA toggle group for bold, italic and