Skip to content
ChibiUI

Built on Radix UI Switch

Switch

An on/off toggle. Mochi sleeps on the thumb when it is off and wakes up, smiling, when it is on.

Playground

Generated code
import { ChibiSwitch } from '@chibi-ui/react/switch';

<ChibiSwitch label="Wake Mochi up" />

Import

TSX
import {
  ChibiSwitch,
} from '@chibi-ui/react/switch';

Examples

react-hook-form Controller
<Controller
  control={control}
  name="newsletter"
  render={({ field }) => (
    <ChibiSwitch
      label="Send me cute newsletters"
      checked={field.value}
      onCheckedChange={field.onChange}
      onBlur={field.onBlur}
      ref={field.ref}
      name={field.name}
    />
  )}
/>

Accessibility

  • role="switch" with aria-checked. Space toggles it, and clicking the label toggles it too.
  • The state is shown by the thumb position and the mascot’s expression, not by colour alone. The track border stays at 3:1 or more in both states.
  • A hidden checkbox mirrors the state for native form submission.

API reference

ChibiSwitch

PropTypeDefaultDescription
labelReactNode—Visible label, associated with the control.
descriptionReactNode—Helper text, linked via aria-describedby.
errorReactNode—Error message (e.g. errors.x?.message). Any truthy value sets aria-invalid; true marks invalid without a message.
containerClassNamestring—Class for the wrapper holding label, control and messages.
checked / defaultCheckedboolean—Controlled / uncontrolled state.
onCheckedChange(checked: boolean) => void—Change callback.
size'sm' | 'md''md'Track size.
labelPosition'start' | 'end''end'Label placement.