Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

Disabled Switch for Solid

A switch named Bluetooth that starts off, faded to half opacity, and left out of the tab order.

UI library: Ark UI

One switch is on screen. It starts off, looks faded, and cannot be toggled. There is no visible label. Its accessible name is Bluetooth.

Use it when a plan or role blocks the setting, and say why in text beside it. A choice that submits later fits a Checkbox. In Solid, Ark UI fades the switch and takes it out of the tab order.

Preview

Preview width

Installation

MCP · Pro
Make your AI a shadcn expert
Your agent installs components, builds pages and restyles your app from one prompt, in Claude Code, Cursor or VS Code.
Part of Pro

Anatomy

Switch anatomy: root, control, thumb, label

Usage

<Switch aria-label="Bluetooth" disabled />

FAQ

How is this switch disabled?

The demo disables the Switch. That sets data-disabled, which fades it to half opacity and sets cursor-not-allowed, and the switch leaves the tab order. The prop is disabled.

How do I tell people why it is disabled?

Say it in text near the switch, such as a FieldDescription under its label. A disabled control can't take focus, so a tooltip on the switch itself won't open from the keyboard.

How do I control this switch in Solid?

Nothing in this file sets the on state, so the switch starts off and keeps its own state. To control it, keep the on or off state in your own state and pass it back. To start it on, use the default prop. The prop is defaultChecked. Pass checked; onCheckedChange receives details.checked.

What do screen readers call this switch?

It has no visible label, so the demo passes aria-label (Bluetooth). Change it to the setting the switch controls, or use a visible FieldLabel instead.

How do I add a visible label to this switch?

Put the Switch in a horizontal Field next to a FieldLabel. Clicking the label toggles the switch, and screen readers read the label with it. The Field links the label to the switch for you.

Does this switch submit with a form?

Give it a name. When on, it submits its value, which defaults to on. When off, it submits nothing.

API Reference

Switch

Sets aria-label="Bluetooth" and disabled. The rest is on the Switch page.