Skip to main content
Mantı UI logoMantı UIv0.13.0
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.
checkedboolean—Controlled checked state.
defaultCheckedboolean—Initial checked state when uncontrolled.
onCheckedChange(checked: boolean) => void—Called whenever the checked state changes.
childrenReactNode—Optional trailing label.
disabledboolean—Disable the control.
name / valuestring—Form field name and submitted value when checked.
rootProps / inputPropsLabelHTMLAttributes / InputHTMLAttributes—Props 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