Disabled Reason

Disabled Reason is a copy-paste React component that stops disabled button with no reason given before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/disabled-reason
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 3 extra npm packages
  • A11y guidance in docs

StopsDisabled button with no reason given

Was this component page useful?

How do I install Disabled Reason?

pnpm dlx shadcn@latest add @bollard/disabled-reason

The files land in your project. They're yours to edit.

How do I use Disabled Reason in React?

disabled-reason-usage.tsx
import { DisabledReason, type BlockedReason } from "@/components/ui/disabled-reason"

<DisabledReason reasons={published ? [] : reasons} side="bottom" align="end" defaultOpen heading="Can't publish yet">
  <button
    type="button"
    onClick={() => setPublished(true)}
    className="inline-flex h-9 items-center rounded-md bg-primary px-4 text-sm font-medium text-primary-foreground shadow-xs transition-colors hover:bg-primary/90 outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50"
  >
    {published ? "Published" : "Publish"}
  </button>
</DisabledReason>

What input mistakes does Disabled Reason catch?

  • Disabled buttons that give no reason
  • Every blocker at once, with a link to fix each
  • Presses on a blocked control, acknowledged with a shake

What props does Disabled Reason accept?

DisabledReason props
PropTypeDefault
reasons* (required)

What's blocking the control. An empty list means it's usable and the wrapper steps aside.

(BlockedReason | string)[]—
children* (required)

The button or control to wrap. Don't give it `disabled`; this sets `aria-disabled` instead.

React.ReactElement<TriggerProps>—
heading

First line of the explanation.

string"Not available yet"
readyMessage

Read to screen readers when the control becomes usable.

string"Ready. You can use it now."
side

Preferred side for the explanation; it flips when there's no room.

"top" | "bottom""top"
align

Which edge of the control it lines up with.

"start" | "end""start"
open

Controlled open state of the explanation.

boolean—
defaultOpen

Initial open state when uncontrolled.

booleanfalse
onOpenChange

Called when the explanation opens or closes.

(open: boolean) => void—

* required. Also accepts the native props of <span> (className, aria-*, data-*…), passed through to it.

How is Disabled Reason accessible?

  • Sets aria-disabled on the child instead of disabled, so it stays focusable
  • Adds aria-describedby to the reasons while blocked
  • Opens on focus as well as hover and tap
  • The shake and list animations respect prefers-reduced-motion

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

  • Only lists the reasons you pass; it doesn't validate the form
  • Don't also set `disabled` on the child, or it can't receive focus

What expensive mistakes does Disabled Reason stop?

Disabled button with no reason given

Also known as

disabled button · aria-disabled · tooltip · submit button · form validation · continue button · requirements · checkout button

What dependencies does Disabled Reason require?

Disabled Reason facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameDisabled Reason
Registry identifier@bollard/disabled-reason
Install commandnpx shadcn@latest add @bollard/disabled-reason
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react, @floating-ui/react, motion
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Disabled Reason

How does Disabled Reason prevent financial transaction errors?

Disabled Reason prevents disabled button with no reason given. Blocks Disabled buttons that give no reason, Every blocker at once, with a link to fix each, Presses on a blocked control, acknowledged with a shake before processing. Limitation: apply idempotency keys for disabled-reason.

How do I install disabled-reason with shadcn?

Run `npx shadcn@latest add @bollard/disabled-reason`. Sources added: registry/default/disabled-reason/disabled-reason.tsx. Package requirements: lucide-react, @floating-ui/react, motion.

What props customize Disabled Reason?

Disabled Reason accepts `reasons`, `children`, `heading`, `readyMessage`, `side`. Configures disabled button, aria-disabled, tooltip behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of disabled-reason?

Only lists the reasons you pass; it doesn't validate the form. Don't also set `disabled` on the child, or it can't receive focus Server requirement: backend verification for disabled-reason.

How does Disabled Reason meet accessibility guidelines?

Sets aria-disabled on the child instead of disabled, so it stays focusable. Adds aria-describedby to the reasons while blocked. Opens on focus as well as hover and tap. The shake and list animations respect prefers-reduced-motion. Minimizes errors: why is submit disabled, disabled button no explanation.

Which components pair with Disabled Reason?