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
Settings Panel
Settings Panel
Multiple switches in a settings-like layout
Premium Features
Enable advanced functionality
Notifications
Receive email updates
Custom Labels
Custom Labels
Switches with custom on/off labels
Disabled States
Disabled States
Switches in disabled state
Disabled Off
Disabled On
Form Integration
Form Integration
Switch integrated with form labels
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
checkedboolean"false"Whether the switch is in the on position
checkedboolean"false"Whether the switch is in the on position
onChange(event: ComponentEvent<boolean>) => voidCallback fired when switch state changes. Receives event object with value, name, and args properties
onChange(event: ComponentEvent<boolean>) => voidCallback fired when switch state changes. Receives event object with value, name, and args properties
onLabelstring"'On'"Label text displayed when switch is on
onLabelstring"'On'"Label text displayed when switch is on
offLabelstring"'Off'"Label text displayed when switch is off
offLabelstring"'Off'"Label text displayed when switch is off
labelstringOptional descriptive label for the toggle's purpose, rendered before the switch and used for screen readers
labelstringOptional descriptive label for the toggle's purpose, rendered before the switch and used for screen readers
ariaLabelstringAccessible label override for the switch button
ariaLabelstringAccessible label override for the switch button
size'xs' | 'sm' | 'md' | 'lg' | 'xl'"'md'"Switch size
size'xs' | 'sm' | 'md' | 'lg' | 'xl'"'md'"Switch size
disabledboolean"false"Whether the switch is disabled
disabledboolean"false"Whether the switch is disabled
requiredboolean"false"Mark the switch as required
requiredboolean"false"Mark the switch as required
idstringHTML id attribute for the switch input
idstringHTML id attribute for the switch input
namestringName attribute for the switch input (used in forms)
namestringName attribute for the switch input (used in forms)
argsanyAdditional arguments passed to onChange handler
argsanyAdditional arguments passed to onChange handler
classNamestringAdditional CSS classes for the container
classNamestringAdditional 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