# Shadcn UI Switch

> Add toggle switches with ShadSwitch and ShadSwitchFormField; label, form validation. Use when adding on/off toggles or switch form fields in a Flutter shadcn_ui app or ShadForm.

- Skill: `serverpod/shadcn-ui-switch` (Agent Skill)
- Install (CLI): `npx skillmds@latest add serverpod/shadcn-ui-switch`
- Raw SKILL.md: https://api.skillmd.com/api/skills/serverpod/shadcn-ui-switch/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: serverpod (https://skillmd.com/u/serverpod)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/serverpod/shadcn-ui-switch

---


# Shadcn UI — Switch

## Instructions

`ShadSwitch` is a control that toggles between checked and unchecked. Use `value` and `onChanged`; optional `label`. For forms use `ShadSwitchFormField` with `id`, `initialValue`, `inputLabel`, `inputSublabel`, `validator`.

### Standalone

```dart
ShadSwitch(
  value: value,
  onChanged: (v) => setState(() => value = v),
  label: const Text('Airplane Mode'),
)
```

### Form field

```dart
ShadSwitchFormField(
  id: 'terms',
  initialValue: false,
  inputLabel: const Text('I accept the terms and conditions'),
  onChanged: (v) {},
  inputSublabel: const Text('You agree to our Terms and Conditions'),
  validator: (v) {
    if (!v) return 'You must accept the terms and conditions';
    return null;
  },
)
```

