Next to the properties listed in the propstable, a collection of system props can be added to any component for further general styling and layouting purposes. These props vary per component.
Make a Switch selected by passing the checked prop.
Label
<Switchid="checked"label="Label"checked/>
Disabled
default: undefined
Marking a Switch as disabled, will disable all interaction with the element.
Label
<Switchid="disabled"label="Label"disabled/>
Error
default: undefined
To convey an error to the user, you can set the error prop to true.
Label
The visual style is only passed to the message.
<Switch
id="error"
label="Label"
message="The visual style is only passed to the message."
error
/>
LabelHidden
default: undefined
To meet accessibility requirements, every Switch should have an associated
label. We do support the ability to visually hide the label when the Switch's
purpose is clear.
Label
<Switchid="labelHidden"label="Label"labelHidden/>
LabelPlacement
default: undefined
The positioning of the label against the switch itself. The full label will move
position (also action, message & optionalLabel).
You can visually change the label of the Switch. For more info about the
possibilities, check the Text component's
documentation (Label inherits the Text).
Label
<Switch
mb={5}
id="labelProps"
label="Label"
labelProps={{
color:'primaryBase',
decoration:'line-through',
fontFamily:'primary',
fontWeight:'regular',
size:'Heading2',
textTransform:'capitalize',
}}
/>
Message
default: undefined
Give additional information to the user.
Label
Message can be set to provide additional information.
<Switch
id="message"
label="Label"
message="Message can be set to provide additional information."
/>
OptionalLabel
default: undefined
Compared with TextField, the Switch is not required by default. The
optionalLabel is additional feedback to the user, please provide it where
needed.