Skip to main content
Mantı UI logoMantı UIv0.12.1
Studio

Switch

Use defaultChecked for uncontrolled state or checked with onCheckedChange for controlled state. The actual input uses role="switch". children renders a visible label; use inputProps for aria-label or aria-labelledby when the label lives elsewhere.

import { Switch } from '@manti-ui/react';

export default function SwitchBasic() {
  return (
    <>
      <Switch defaultChecked>Wi-Fi</Switch>
      <Switch>Bluetooth</Switch>
      <Switch disabled>Airplane mode</Switch>
    </>
  );
}

Sizes

API

PropTypeDefaultDescription
size'sm' | 'md''md'Control size.
checkedbooleanControlled checked state.
defaultCheckedbooleanInitial checked state when uncontrolled.
onCheckedChange(checked: boolean) => voidCalled whenever the checked state changes.
childrenReactNodeOptional trailing label.
disabledbooleanDisable the control.
name / valuestringForm field name and submitted value when checked.
rootProps / inputPropsLabelHTMLAttributes / InputHTMLAttributesProps for the wrapping label and actual role=switch input.

Styling

Anatomy

PartSelectorDescription
root[data-scope="switch"][data-part="root"]The <label> wrapping the control.
control[data-scope="switch"][data-part="control"]The track.
thumb[data-scope="switch"][data-part="thumb"]The sliding knob.
hidden-input[data-scope="switch"][data-part="hidden-input"]Visually hidden checkbox input.
label[data-scope="switch"][data-part="label"]Optional trailing label text.

Tokens

TokenControls
--manti-switch-track-widthtrack width
--manti-switch-track-heighttrack height
--manti-switch-track-paddingtrack padding

Last updated

Built end-to-end with Manti UI components and design tokens. Manti UI is a framework-agnostic design system on Zag.js.

GitHub