Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Checkbox examples · Standard

Disabled Checkbox for React

Two disabled checkboxes, one unchecked and one checked, for options people can see but not change.

Framework
UI library

Sometimes an option should be visible but out of reach. This example shows both disabled states: an empty box and a checked one. The checkbox is disabled, and data-disabled on each Field fades the label with the box, so the whole row reads as unavailable and clicks do nothing. Use it for features a plan doesn't include, read-only views of saved settings, or options that depend on another choice.

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 disable checkboxes instead of hiding them?

Disable an option people should know exists but can't use right now: a feature on a higher plan, a choice that needs another one first, a setting that's locked. Hide it when it doesn't apply to them at all. Either way, say why nearby when it isn't obvious.

How do I show a disabled checkbox as checked?

Start it checked and disable it, as the second row does. It reads as "this is on and can't be changed", for included features or requirements already met. Pass defaultChecked (or a controlled checked) together with disabled.

Why does the label fade too?

data-disabled on the Field dims its label to match the box. A faded box next to full-strength text looks like a bug; dimming the whole row says the entire option is unavailable.

How do I conditionally disable checkboxes based on other form state?

Compute the disabled flag from your state and pass it on every render, for example when a parent option is off or a selection limit is reached. Put the same condition on the field's data-disabled, and add a line of helper text such as "Select up to 3" so people know why.

Are disabled checkboxes accessible to screen readers?

Screen readers announce them as dimmed or unavailable, along with their checked state, but keyboard users can't tab to them. If the reason matters, put it in text before the checkbox so it's read in order.

What's the difference between disabled and readonly checkboxes?

A disabled checkbox can't be focused and isn't submitted with the form. A read-only one stays focusable and submits its value, but can't be changed. Use read-only when a locked value still has to reach the server. Pass readOnly.