Skip to main content

Switch

A toggleable on/off switch control.

When to use it

Use a Switch for a binary on/off setting that takes effect immediately — for example, toggling a preference. Pass null for onChanged to render the switch as disabled.

Import

import 'package:catalyst_ui/catalyst_ui.dart';

Usage

Switch(
value: _isOn,
onChanged: (v) => setState(() => _isOn = v),
)

Parameters

ParameterTypeDefaultDescription
valueboolrequiredWhether the switch is currently on.
onChangedValueChanged<bool>?requiredCalled when the user toggles the switch. null disables.
sizeSwitchSizeSwitchSize.mediumThe size variant.

Sizes

SwitchSize values: small (32×18px track, 14px knob), medium (44×24px track, 20px knob, default), large (52×30px track, 26px knob).