Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Checkbox examples · Standard

Right-Aligned Checkbox for React

A list of notification settings with each label at the start of its row and the checkbox at the end.

Framework
UI library

Labels first, boxes at the end: the layout of a settings screen. Each row is a horizontal Field with the FieldLabel before the Checkbox; the label stretches to fill the row, which pushes the box to the end edge so the three boxes line up in a column. The ends follow the reading direction, so a right-to-left page mirrors it. Use it for notification channels, privacy options and other lists of independent on/off settings.

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 use right-aligned checkboxes?

For settings, where each row is an option people turn on or off and they scan the labels first. This demo puts FieldLabel before the checkbox, and the label grows so the box sits at the end of the row.

Should I use right-aligned checkboxes or toggle switches?

It depends on when the change applies. Use checkboxes when the settings are saved with a button. Use a Switch when each one takes effect immediately. The same row, label then control, works for both.

How do the checkboxes line up with different label lengths?

The label grows to fill whatever the box doesn't use, so every box sits at the end edge whatever the label's length, and they form one column. The list is capped at max-w-xs here; very long labels wrap inside their own space.

Do right-aligned checkboxes work well on mobile?

Yes. The stretched label is clickable, so tapping anywhere along the row's text toggles the box, not just the box itself. On touch screens, give rows more height (a larger gap-*, or padding on each Field) so neighbors are hard to hit by mistake.

How do I group right-aligned checkboxes by category?

Give each category its own FieldSet with a FieldLegend (Notifications, Privacy), and separate the sets with a FieldSeparator or more space. A legend also names the group for screen readers.

Are right-aligned checkboxes accessible?

Yes. The label comes first in the source as well as on screen, so screen readers read the setting before the box's state, and Tab order matches what people see. The layout is only flexbox; each label stays linked to its checkbox.