Switch Toggle
A specialized toggle switch component that extends the Checkbox functionality, providing a modern, visually appealing way to represent binary choices.Basic Switch Toggle
Creates a standard switch toggle with a name and label.
Options
The Switch component supports various configuration options.bsStyle
: Bootstrap style for the switch (default: 'primary')size
: Size of the switch (from SwitchSizeEnum)alignRight
: Whether to align the switch to the right (default: false)checked
: Whether the switch is checked (inherited from Checkbox)disabled
: Whether the switch is disabled (inherited from Checkbox)required
: Whether the switch is required (inherited from Checkbox)value
: The value of the switch when checked (inherited from Checkbox)
Switch Examples
Here are examples of different ways to use the switch component.Styled Switch
Creates a switch with custom Bootstrap styling.
Sized Switch
Creates a switch with custom size.
Full-featured Switch
Creates a switch with all available customizations.
API
The switch component extends from theCheckbox
class so it has all its methods available.Common alternative names: Toggle Switch, Binary Switch, On/Off Switch, Toggle Button, Flip Switch, Slider Switch, Binary Toggle
Types: Basic Switch, Styled Switch, Sized Switch, Right-aligned Switch, Required Switch, Disabled Switch, Checked Switch
Principles
Visual Feedback
Switch toggles provide immediate visual feedback through their sliding animation and color changes, making the current state clear to users.
Binary Clarity
The component's design emphasizes the binary nature of the choice, making it clear that there are only two possible states.
Accessibility
Switch toggles maintain keyboard accessibility and screen reader compatibility while providing a modern visual interface.
Anatomy

- Container
- Input
- Toggle
- Label
- Track
- Thumb
Outer wrapper div with 'form-switch' class
Hidden checkbox input element
Visual sliding element
Text description of the switch's purpose
Background element that the toggle slides along
The moving part of the switch
Usage
Use switch toggles for:
- Feature toggles
- Settings options
- Binary choices
- On/off states
- Enable/disable controls
- Mode switches
- Preference settings
Best Practices
- Use clear, concise labels that describe the action
- Consider the visual hierarchy when placing multiple switches
- Use appropriate styling to indicate the importance of the switch
- Provide immediate feedback when the switch is toggled
- Consider the context when choosing between a switch and other input types
- Use consistent styling across related switches
- Ensure the switch is large enough to be easily clickable
Common Patterns
Settings Panels
- User preferences
- Feature flags
- Notification settings
- Privacy controls
- Display options
Form Controls
- Required field indicators
- Form validation toggles
- Auto-save controls
- Advanced options
- Batch operations
Interface Controls
- Dark/light mode
- Layout options
- View preferences
- Filter toggles
- Sort options
Accessibility
- Ensure proper ARIA attributes are set
- Maintain keyboard navigation support
- Provide clear focus states
- Use appropriate color contrast
- Include descriptive labels
- Consider screen reader announcements
- Test with various assistive technologies