Switch
The Switch component can be imported as follows:
Examples
Basic Usage
Code
Customizing Sizes
Code
Customizing Color
Code
State Behavior
isChecked
: This state represents whether the Switch is checked or not. By setting the isChecked prop to true, the Switch will be initially checked.isDisabled
: When the isDisabled prop is set to true, the Switch becomes disabled and cannot be interacted with. It is commonly used to indicate that a particular option or feature is not available or applicable in the current context.isFocusable
: The isFocusable prop determines whether the Switch can receive focus or not. When both isFocusable and isDisabled are true, the Switch is visually disabled but can still receive focus. This can be useful for keyboard accessibility in certain scenarios.isInvalid
: The isInvalid prop is used to indicate that the Switch has an invalid or erroneous value. It typically triggers error styling, such as displaying a red border or showing an error message nearby. This state is useful for form validation.isReadOnly
: Setting the isReadOnly prop to true makes the Switch read-only, meaning the user cannot toggle its state. This is often used when displaying data or settings that cannot be modified.isRequired
: The isRequired prop is used to mark the Switch as a required input field. It indicates that the user must interact with the Switch to fulfill a form submission or satisfy certain criteria.Code
Did you know?
Creative Idea No. 1
Code
Creative Idea No. 2
🇬🇧
🇫🇷
Code
Creative Idea No. 3
😐
🪩
⛔️
⛔️
⛔️
⛔️
Code
copyright © 2023 IHeartComponents | evanmarie.com
created with love by the I♥️Components team using
Special thanks to Stefan Bohacek / Generative Placeholders.