Fluxo UIFluxo UIv0.4.1

InputSwitch

A toggle switch component for binary choices, providing an alternative to checkboxes for on/off states.

Basic Usage

Basic Switch

Simple on/off toggle switch

OffOn
Disabled

Settings Panel

Settings Panel

Multiple switches in a settings-like layout

Premium Features

Enable advanced functionality

OffOn

Notifications

Receive email updates

OffOn

Custom Labels

Custom Labels

Switches with custom on/off labels

NoYes
InactiveActive
DisabledEnabled

Disabled States

Disabled States

Switches in disabled state

OffOn

Disabled Off

OffOn

Disabled On

Form Integration

Form Integration

Switch integrated with form labels

OffOn
OffOn
OffOn

Usage

Basic Usage

import { InputSwitch } from 'fluxo-ui';

function MyComponent() {
  const [enabled, setEnabled] = useState(false);

  return (
    <InputSwitch
      checked={enabled}
      onChange={(e) => setEnabled(e.value)}
    />
  );
}

Advanced Usage

import { InputSwitch } from 'fluxo-ui';

function MyComponent() {
  const [settings, setSettings] = useState({
    notifications: true,
    darkMode: false,
    autoSave: true
  });

  const handleSettingChange = (key, value) => {
    setSettings(prev => ({ ...prev, [key]: value }));
  };

  return (
    <div className="space-y-4">
      <div className="flex items-center justify-between">
        <label>Enable Notifications</label>
        <InputSwitch
          checked={settings.notifications}
          onChange={(e) => handleSettingChange('notifications', e.value)}
          onLabel="On"
          offLabel="Off"
        />
      </div>

      <div className="flex items-center justify-between">
        <label>Dark Mode</label>
        <InputSwitch
          checked={settings.darkMode}
          onChange={(e) => handleSettingChange('darkMode', e.value)}
          onLabel="Enabled"
          offLabel="Disabled"
        />
      </div>
    </div>
  );
}

Import

import { InputSwitch } from 'fluxo-ui';

Props

checked
boolean"false"

Whether the switch is in the on position

onChange
(event: ComponentEvent<boolean>) => void

Callback fired when switch state changes. Receives event object with value, name, and args properties

onLabel
string"'On'"

Label text displayed when switch is on

offLabel
string"'Off'"

Label text displayed when switch is off

label
string

Optional descriptive label for the toggle's purpose, rendered before the switch and used for screen readers

ariaLabel
string

Accessible label override for the switch button

size
'xs' | 'sm' | 'md' | 'lg' | 'xl'"'md'"

Switch size

disabled
boolean"false"

Whether the switch is disabled

required
boolean"false"

Mark the switch as required

id
string

HTML id attribute for the switch input

name
string

Name attribute for the switch input (used in forms)

args
any

Additional arguments passed to onChange handler

className
string

Additional CSS classes for the container

Features

Binary Toggle

Clean on/off toggle with smooth animated thumb transition for clear visual feedback

Custom Labels

onLabel and offLabel props let you display contextual text like Yes/No, Active/Inactive, or Enabled/Disabled

Disabled State

Disabled prop prevents interaction while preserving the current value in both on and off positions

Form Compatible

Supports name attribute for native form submission and integrates cleanly with label elements

Controlled Component

Fully controlled via checked and onChange props — no internal state to fight against

Accessibility

Uses native checkbox semantics with ARIA role="switch", keyboard toggling, and focus ring

Theming

Full dark/light and 5 brand themes supported via CSS variables with zero extra configuration