Photonix

Switch

A toggle control to switch between two states, usually on and off.

Preview

Usage
import { Switch } from '@photonix/ultimate';

<Switch label="Off" />
<Switch label="On" defaultChecked />
<Switch label="Disabled" disabled />

Component API

Switch

Prop
Type
Default
Description
checked
boolean
-
Whether the switch is on (controlled)
defaultChecked
boolean
false
Initial state when uncontrolled
size
"small" | "large"
'large'
Size of the switch
label
React.ReactNode
-
Label text for the switch
onChange
((checked: boolean) => void)
-
Callback when switch state changes

Variants

Basic Controlled

A simple controlled switch.

Basic Controlled
const [checked, setChecked] = useState(false);

<Switch 
  label="Notifications" 
  checked={checked} 
  onChange={setChecked} 
/>

Sizes

Available in small and large (default) sizes.

Large

Small

Sizes
<Switch size="large" label="Large (Default)" defaultChecked />
<Switch size="small" label="Small" defaultChecked />

States

Disabled states.

States
<Switch label="Disabled Off" disabled />
<Switch label="Disabled On" disabled defaultChecked />

On this page

Preview
Component API
Variants
With Label
Sizes
States
Photonix UI - React Components, Templates & Figma Design System