Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Checkbox examples · Standard

With Subtitle Checkbox for React

A checkbox whose label has a short muted subtitle, Recommended, on the same line.

Framework
UI library

Sometimes a label needs a qualifier. Here Enable notifications carries a muted Recommended beside it, on the same line. The FieldLabel and the subtitle sit in a flex items-baseline gap-2 row, so text of different sizes shares a baseline, and only the label toggles the box. Use it to mark recommended, optional, beta or paid options without adding a line of description.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

FAQ

When should I add subtitles to checkboxes?

For a one- or two-word hint that helps the decision: Recommended, Optional, Required, Beta, Pro. Anything longer is an explanation and belongs in a FieldDescription under the label.

How do I style subtitle badges differently?

Change the span's classes: text-primary to make it stand out, or text-destructive for a warning. For a pill, swap the span for a Badge with variant="secondary". Stick to the theme's colors so it works in dark mode.

Why use gap-2 between label and subtitle?

gap-2 (8px) separates the two without making the subtitle look unrelated. items-baseline lines the smaller muted text up with the label's text rather than its box, so the pair reads as one line.

Can some checkboxes have subtitles while others don't?

Yes. In a list, render the span only when the item has a subtitle. Rows without one simply end at the label, and the checkboxes still line up because they come first in each row.

Are subtitle badges announced by screen readers?

The subtitle sits outside the label, so the checkbox's name is just "Enable notifications"; the subtitle is read as nearby text. If the qualifier matters to the choice, move it inside the FieldLabel so it becomes part of the name, and spell it out: "Recommended", not "Rec".

How do I handle long subtitle text?

Keep subtitles to a word or two. If yours runs longer, it is a description: move it under the label. As a fallback, flex-wrap on the row lets the subtitle drop to the next line on narrow screens.