ZBMui

Switch

View markdown

A control that indicates whether a setting is on or off.

Installation

components/ui/switch.tsx

Usage

Examples

Sizes

Three sizes are available.

  • sm: Small size switch. (--spacing(3) / 12px)
  • default: Default size switch. (--spacing(4) / 16px)
  • lg: Large size switch. (--spacing(5) / 20px)

You can customize the size more by overriding the --thumb-size CSS variable. For example, you can set --thumb-size: 1.5rem to make the thumb size 24px.

Disabled

Invalid

With description

By enabling marketing emails, you agree to receive emails.

Card style

Controlled

Form integration

For demonstrating invalid state, the default value is set to undefined. Without toggling the switch, the switch will be in an invalid state when the form is submitted.

ZBMui

Built by the ZBM.

© 2026 ZBM ui. All rights reserved.