Switch

An on/off control for settings that apply immediately — not a checkbox waiting on a submit.

Source
1 file
Dependencies
none
Playground
yes

Examples

Every variant of the shipped component, live. Switch the layout to read them as a table or one at a time, and open Code for the file behind them.

01Basic
02Size
03Variant
04Appearance
05Radius
06With icons
07Icon in thumb
08Track & thumb width
09With label
10Disabled

Installation

One package for the whole library — run this once and every component on this site is importable. Adding the tokens to your stylesheet is the other half; the installation guide covers it.

npm install kipui
import { Switch } from "kipui";
Peer dependencies

react 19

react-dom 19

tailwindcss 4

Bundled dependencies

None beyond the peers above.

Usage

switch-example.tsx
import { Switch } from "kipui";

<Switch
  defaultChecked
  size="md"
  onCheckedChange={(checked) => save(checked)}
/>
  • Use a switch when the change takes effect at once; use a checkbox when it takes effect on submit.
  • `showIcons` plus `iconPlacement` decides whether the check/cross sits on the track or rides in the thumb.

Playground

Change the props and the snippet underneath updates with them.

Preview

<Switch />

Props

6
<Switch
  size="sm"
  variant="primary"
  appearance="solid"
  radius="full"
/>

API reference

Transcribed from the component's own types. Props with no default are required.

PropDefaultDescription
checkedbooleanrequiredControlled state.
defaultCheckedbooleanfalseUncontrolled seed.
onCheckedChange(checked: boolean) => voidrequiredFires with the next state.
variant"primary" | "success" | "warning" | "destructive" | "secondary""primary"Colour of the on state.
size"sm" | "md" | "lg""sm"Track and thumb size.
appearance"solid" | "soft" | "outline""solid"Surface treatment of the track.
radius"none" | "sm" | "md" | "lg" | "full""full"Corner radius of the track.
showIconsbooleanfalseDraws a check and cross for the two states.
namestringrequiredSubmits with the surrounding form under this name.
disabledbooleanfalseBlocks interaction and dims the track.
valuestring | number"on"Value posted while checked, matching a checkbox.
iconPlacement"track" | "thumb""track"Where `showIcons` puts the check and cross.
trackWidthstring | numberrequiredOverrides the track width for the chosen `size`.
thumbWidthstring | numberrequiredOverrides the thumb width for the chosen `size`.