Switch

An animated toggle switch component for boolean settings. Built with Framer Motion for smooth spring-based animations. Supports labels, descriptions, color variants, and configurable label positioning.

Import

import { Switch } from '@wavebooking/aqua-fusion';

Preview

Loading preview...

Usage

<Switch
  checked={enabled}
  onChange={(e) => setEnabled(e.target.checked)}
/>

<Switch
  label="Email notifications"
  description="Receive weekly digest emails"
  checked={notifications}
  onChange={handleChange}
/>

<Switch
  label="Dark mode"
  variant="success"
  size="lg"
  labelPosition="left"
  checked={darkMode}
  onChange={handleChange}
/>

Props

PropTypeDefaultDescription
labelstring-Label text displayed next to the switch.
descriptionstring-Description text rendered below the label.
labelPosition'left' | 'right''right'Position of the label relative to the switch.
size'sm' | 'md' | 'lg''md'Size of the switch track and thumb.
variant'default' | 'success' | 'warning' | 'error''default'Color variant applied when the switch is checked.
checkedbooleanfalseControlled checked state of the switch.
onChange(e: ChangeEvent<HTMLInputElement>) => void-Change event handler fired when the switch is toggled.
disabledbooleanfalseWhether the switch is disabled.
classNamestring-Additional CSS classes to apply to the switch track.

The component also accepts all standard HTML <input> attributes (except size).