Toggle Disabled

A disabled version of the shadcn/ui Toggle that shows an underline icon button in a non-interactive state. It demonstrates how the Toggle's disabled prop blocks pressing and dims the control.

Toggle Disabled
LIVE · running in a sandboxed iframe
Installed with plain shadcn add · no workarounds · theme neutral (none shipped)
See how it was built

Installation

pnpm dlx shadcn@latest add https://ui.shadcn.com/r/styles/new-york-v4/toggle-disabled.json

Usage

usage.tsx
import { Underline } from "lucide-react"import { Toggle } from "@/components/ui/toggle"export default function ToggleDisabled() {  return (    <Toggle aria-label="Toggle underline" disabled>      <Underline className="h-4 w-4" />    </Toggle>  )}
  • Show a formatting or view toggle that exists in the UI but is unavailable in the current context
  • Demonstrate the disabled state of the Toggle component in documentation or a design system showcase
  • Reserve a toolbar slot for a feature that is locked by permissions, plan tier, or missing selection
  • Indicate that a toggle becomes available only after another action is completed

Examples

Disabled icon toggle

The exact registry example: an icon-only Toggle with the disabled prop set, so it cannot be pressed.

disabled-icon-toggle.tsx
import { Underline } from "lucide-react"import { Toggle } from "@/components/ui/toggle"export default function ToggleDisabled() {  return (    <Toggle aria-label="Toggle underline" disabled>      <Underline className="h-4 w-4" />    </Toggle>  )}

Disabled toggle with pressed state

A disabled Toggle that is already pressed, showing a locked on state such as a setting enforced by an admin.

disabled-toggle-with-pressed-state.tsx
import { Underline } from "lucide-react"import { Toggle } from "@/components/ui/toggle"export default function LockedUnderlineToggle() {  return (    <Toggle aria-label="Underline enforced by policy" pressed disabled>      <Underline className="h-4 w-4" />    </Toggle>  )}

Disabled outline variant with label

A disabled outline-variant Toggle paired with visible text so the unavailable option is still readable.

disabled-outline-variant-with-label.tsx
import { Bold } from "lucide-react"import { Toggle } from "@/components/ui/toggle"export default function DisabledBoldToggle() {  return (    <Toggle variant="outline" disabled>      <Bold className="h-4 w-4" />      Bold    </Toggle>  )}

API reference

PropTypeDefaultDescription
disabledbooleanfalsePassed through to the underlying Radix Toggle root. When true, the toggle cannot be pressed and receives disabled styling. This is the prop the example demonstrates.
pressedboolean—Controlled pressed state of the toggle, forwarded to the Radix Toggle root.
defaultPressedbooleanfalseInitial pressed state when the toggle is uncontrolled.
onPressedChange(pressed: boolean) => void—Callback fired when the pressed state changes. Not called while disabled.
variant"default" | "outline""default"Visual style variant from toggleVariants, defined in the toggle component.
size"default" | "sm" | "lg""default"Size variant from toggleVariants, controlling padding and height.
aria-labelstring—Accessible name. Required here because the toggle contains only an icon with no visible text.

Accessibility

  • The disabled attribute is forwarded to the underlying button, so it is removed from interaction and communicated to assistive technology as unavailable.
  • An icon-only toggle needs an aria-label; the example supplies one.
  • The example's aria-label reads "Toggle italic" while the icon is Underline. Use a label that matches the icon, such as "Toggle underline", so screen reader users are not misled.
  • Radix Toggle exposes the pressed state through aria-pressed, so assistive technology announces on or off when the toggle is enabled.
  • Disabled controls are excluded from keyboard tab order, so do not rely on a disabled toggle to explain itself; add nearby text or a tooltip describing why it is unavailable.

Docs written by anthropic:claude-haiku-5-5 from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "Toggle Disabled" component (shadcn-ui/toggle-disabled) from its shadcn registry.1. Install it with: npx shadcn@latest add https://ui.shadcn.com/r/styles/new-york-v4/toggle-disabled.json2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: disabled, pressed, defaultPressed, onPressedChange, variant, size, aria-label.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { Underline } from "lucide-react"import { Toggle } from "@/components/ui/toggle"export default function ToggleDisabled() {  return (    <Toggle aria-label="Toggle underline" disabled>      <Underline className="h-4 w-4" />    </Toggle>  )}```

Files & dependencies

  • registry/new-york-v4/examples/toggle-disabled.tsx
registryDependenciestoggle
Uses from @shadcn-ui

Looks similar, elsewhere