Skip to content

Switch

Used to capture a binary state.

Value:false
import { useState } from 'react';
import { Switch } from '@fintech-sandpit/ui/react';
const [accepted, setAccepted] = useState(false);
return (
<Switch
value={accepted}
onChange={setAccepted}
>
Turn on the lights
</Switch>
);
NameTypeDefaultDescription
valuebooleanThe value of the switch (controlled)
defaultValuebooleanThe default value of the switch (uncontrolled)
colorSchemeColorSchemeneutralThe color scheme of the switch
sizeSizemdThe size of the switch
disabledbooleanfalseWhether the switch is disabled
readOnlybooleanfalseWhether the switch is read only
invalidbooleanfalseWhether the switch is invalid
NameDescription
defaultThe label of the switch
NameTypeDescription
onChange(value: boolean) => voidEvent handler for when the value changes
type ColorScheme = 'neutral' | 'primary' | 'secondary' | 'success' | 'warning' | 'danger'
type Size = 'xs' | 'sm' | 'md' | 'lg' | 'xl'