Skip to Content
Nextra 4.0 is released 🎉

Switch

The Switch component offers a pixel-art styled toggle control for enabling or disabling settings in a retro-inspired interface.
It supports labels, custom colors, themes, and different visual types—allowing you to create expressive and nostalgic toggle interactions while maintaining full flexibility and accessibility.


Select basic example


<Switch label="Note" name="name" type="main" onChange={mockFunction} />

Select type


<Switch label="Note" name="name" type="main" onChange={mockFunction} /> <Switch label="Note" name="name" type="inline" onChange={mockFunction} />

Select default checked


<Switch label="Note" name="name" type="main" onChange={mockFunction} defaultChecked />

Select no label


<Switch label="Note" name="name" type="main" onChange={mockFunction} noLabel />

Select custom color


<Switch label="Note" name="name" type="main" onChange={mockFunction} backgroundColor="#05EB57" />

Select styles


<Switch label="Note" name="name" type="main" onChange={mockFunction} backgroundColor="#05EB57" />

đź”§ Props

PropTypeDefaultDescription
labelstring—The text label displayed next to the Switch.
typeSwitchType—Determines the visual style of the Switch.
namestring—A unique name identifier for the Switch input.
defaultCheckedbooleanfalseSets the initial checked state of the Switch.
noLabelbooleanfalseHides the label when set to true.
backgroundColorstringundefinedSets a custom background color for the Switch container.
classNamestringundefinedAdds additional CSS classes for custom styling.
switchStyleSwitchStyleundefinedApplies a predefined PixelartUI style or theme to the Switch.
onChange(e: React.ChangeEvent<HTMLInputElement>) => void—Callback fired when the Switch value changes.
Last updated on