Skip to main content

Toggle

Toggle switch control for boolean selections.

Basic Usage

import { Toggle } from '@multinaire/ui';

<Toggle
value={isEnabled}
onChange={setIsEnabled}
/>

Props

PropTypeDefaultDescription
valuebooleanWhether the switch is on
colorColorKeys'success'Active track color from the theme palette
testIDstringTest identifier for UI automation
onChange(value: boolean) => voidCallback invoked when the switch state changes
marginSpacingPropsOuter margin

Examples

Basic Toggle

const [isEnabled, setIsEnabled] = useState(false);

<Toggle
value={isEnabled}
onChange={setIsEnabled}
/>

Notifications Settings

<Container gap={16}>
<Toggle
value={pushNotifications}
onChange={setPushNotifications}
/>
<Toggle
value={emailNotifications}
onChange={setEmailNotifications}
/>
</Container>

Read-only

<Toggle value={isActive} />

With Margin

<Toggle
value={isEnabled}
onChange={setIsEnabled}
margin={{ top: 16 }}
/>