shadcn.io is not affiliated with official shadcn/ui
Checkbox examples · Standard
With Description Checkbox for React
A checkbox with a label and a line of description text that explains what the option does.
Some options need more than a few words. Here a Marketing emails checkbox has a muted sentence under its label saying what people will receive. FieldContent stacks the FieldLabel and FieldDescription, and the horizontal Field keeps the box aligned with the label's first line however far the description wraps. Use it for opt-ins, data sharing and other settings whose consequence is easy to miss.
Preview
Installation
FAQ
When should I add description text to checkboxes?
When the label alone doesn't say what checking it means: what an email list will send, what data is shared, what a permission allows. If people would ask "what does this do?", add a description. Skip it for self-explanatory options like "Enable dark mode".
How long should description text be?
One or two short sentences. The description explains the consequence; it isn't a policy. Link to full terms when there is more to say, and keep each line quick to scan.
Why is the description muted?
FieldDescription uses text-muted-foreground at a smaller size, so the label reads first and the description second. The two levels let people decide from the label and read on only when they need the detail.
How does description text wrap on narrow screens?
It wraps like any paragraph, and the field caps the block at max-w-sm here. Because the field holds a FieldContent, it aligns its items to the start, so the checkbox stays level with the label instead of drifting to the middle of a tall block.
Related
- With Subtitle and Description CheckboxA checkbox with a Recommended subtitle
- With Subtitle CheckboxA checkbox whose label has a short muted
- Simple CheckboxA checkbox with a label for a single
- Checkbox with Description FieldA checked checkbox with a label and a
- Switch with DescriptionA switch with a label and a line of
- Right-Aligned CheckboxA list of notification settings with each