---
title: "Switch (BloomSwitch) — Bloom UI Primitive"
description: "A 32x18px control that allows the user to toggle between checked and unchecked states."
category: "Form Controls"
url: "https://bloom-platform-ten.vercel.app/ui/switch"
component_name: "BloomSwitch"
pub_package: "bloom_ui"
cli_command: "bloom ui add switch"
last_updated: "2026-08-15"
---

# Switch (`BloomSwitch`)

> A 32x18px control that allows the user to toggle between checked and unchecked states.

**Category:** Form Controls  
**Package:** [`bloom_ui`](https://pub.dev/packages/bloom_ui)  
**CLI Install:** `bloom ui add switch`  
**Web Preview:** [https://bloom-platform-ten.vercel.app/ui/switch](https://bloom-platform-ten.vercel.app/ui/switch)

---

## 📦 Installation & Setup

### 1. Using Bloom CLI (Recommended)
Add the source code directly to your project without rigid package locks:
```bash
bloom ui add switch
```

### 2. Using Pub.dev Package
Add the dependency to your `pubspec.yaml`:
```yaml
dependencies:
  bloom_ui: ^0.1.0
```

### 3. Import in Dart
```dart
import 'package:bloom_ui/bloom_ui.dart';
```

---

## 🚀 Usage Example

```dart
BloomSwitch(
  checked: true,
  label: const Text('Push Notifications'),
  onChanged: (enabled) {
    print('Notifications: $enabled');
  },
)
```

---

## 🛠️ API Reference

**Available Sizes:** `sm (24x14px)`, `defaultSize (32x18px)`

### Properties & Parameters

| Prop | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| `checked` | `bool` | *Required* | Controlled on/off state. |
| `size` | `BloomSwitchSize` | `defaultSize` | Size step (sm or default). |
| `label` | `Widget?` | *Required* | Adjacent label text. |
| `onChanged` | `ValueChanged<bool>?` | *Required* | Callback when toggled. |

---

## 🎨 Theming & Styling

BloomSwitch automatically respects the active `BloomTheme` (including `BloomTheme.novaLight`, `BloomTheme.novaDark`, etc.) and responds seamlessly to dark mode changes, custom border radii, and brand color tokens.

### Theme Overrides Example
```dart
Theme(
  data: Theme.of(context).copyWith(
    extensions: [
      context.bloomTheme.copyWith(
        colors: context.bloomColors.copyWith(
          primary: const Color(0xFF8B5CF6), // Custom Purple Accent
        ),
      ),
    ],
  ),
  child: BloomSwitch(...,
)
```

---

## 🔗 Related Resources
- [Components Gallery](https://bloom-platform-ten.vercel.app/ui)
- [Bloom Theming & Tokens Guide](https://bloom-platform-ten.vercel.app/docs/theming)
- [Application Blocks Catalog](https://bloom-platform-ten.vercel.app/blocks)
- [Bloom CLI Master Overview](https://bloom-platform-ten.vercel.app/docs/cli)
