Toggle Disabled Demo
A demo showing a disabled outline toggle button with a thumbs-down icon, built on the @kanpeki/toggle component. It shows how a toggle looks and behaves when it cannot be pressed.
exampleregistry-item.json
example · no preview
This item cannot be built as published, so there is no live preview: build: ✗ Build failed in 593ms
See how it was built Installation
pnpm dlx shadcn@latest add @kanpeki/toggle-disabled-demo
Requires @kanpeki in the registries of your components.json (shadcn adds official directory namespaces automatically).
Usage
usage.tsx
import { ThumbsDownIcon } from "lucide-react";import { Toggle } from "~/registry/ui/toggle/toggle";<Toggle aria-label="Toggle dislike" isDisabled variant="outline"> <ThumbsDownIcon /></Toggle>- Showing a toggle that exists in the UI but is temporarily unavailable, such as a reaction button before the user is allowed to react.
- Demonstrating the disabled state of the Toggle component in documentation or a component gallery.
- Displaying an icon-only toggle where the action is blocked by permissions or a loading state.
- Reviewing the outline variant with the disabled style in visual regression tests.
Examples
Disabled toggle with an icon
The exact demo: an outline icon toggle that cannot be pressed, labeled for screen readers.
disabled-toggle-with-an-icon.tsx
import { ThumbsDownIcon } from "lucide-react";import { Toggle } from "~/registry/ui/toggle/toggle";export function ToggleDisabledDemo() { return ( <Toggle aria-label="Toggle dislike" isDisabled variant="outline"> <ThumbsDownIcon /> </Toggle> );}Disabled toggle next to an enabled one
Compares a disabled toggle with an enabled toggle to show the difference in state.
disabled-toggle-next-to-an-enabled-one.tsx
import { ThumbsDownIcon, ThumbsUpIcon } from "lucide-react";import { Toggle } from "~/registry/ui/toggle/toggle";export function ToggleDisabledComparison() { return ( <div className="flex items-center gap-2"> <Toggle aria-label="Toggle like" variant="outline"> <ThumbsUpIcon /> </Toggle> <Toggle aria-label="Toggle dislike" isDisabled variant="outline"> <ThumbsDownIcon /> </Toggle> </div> );}API reference
PropTypeDefaultDescription
aria-labelstring—Accessible name for the icon-only toggle. Required because the button has no visible text. Used as given in the demo ("Toggle dislike").
isDisabledboolean—Disables the toggle so it cannot be pressed and is shown in its disabled style. Passed as a boolean attribute in the demo.
variant"outline" (as used in this demo)—Visual variant of the toggle. This demo uses "outline". The full set of accepted variants is defined in the @kanpeki/toggle source, which is not included in this item.
Accessibility
- The toggle has an aria-label ("Toggle dislike") because it contains only an icon. Keep a meaningful label that describes the action, not the icon.
- isDisabled removes the control from interaction, so keyboard users cannot focus or activate it. Explain why it is disabled nearby if the reason matters to the user.
- The ThumbsDownIcon is decorative. Do not add a separate visible label that repeats the aria-label.
- Verify the disabled contrast of the outline border and icon against the background to meet WCAG contrast guidance, since disabled controls are exempt from contrast requirements but should still be readable.
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 Demo" component (kanpeki/toggle-disabled-demo) from its shadcn registry.1. Install it with: npx shadcn@latest add @kanpeki/toggle-disabled-demo2. 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: aria-label, isDisabled, variant.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { ThumbsDownIcon } from "lucide-react";import { Toggle } from "~/registry/ui/toggle/toggle";<Toggle aria-label="Toggle dislike" isDisabled variant="outline"> <ThumbsDownIcon /></Toggle>```Files & dependencies
- src/registry/examples/toggle/toggle-disabled-demo.tsx
registryDependencies@kanpeki/toggle
Looks similar, elsewhere
There is no screenshot of this item to compare yet.