Adaptive Switch

Adaptiveness

  • Android & iOS: native styling
import AdaptiveModeDemo from "@/shared/adaptiveModeDemo";
import { AdaptiveSwitch } from "adaptive-material-ui/components/switch";

export default function () {
  return (
    <AdaptiveModeDemo>
      <AdaptiveSwitch defaultChecked />
    </AdaptiveModeDemo>
  );
}

Variations

Color
Size
Icon
Disabled
import AdaptiveModeDemo from "@/shared/adaptiveModeDemo";
import { DemoList, DemoListItem } from "@/shared/demoList";
import CheckIcon from "@mui/icons-material/Check";
import CloseIcon from "@mui/icons-material/Close";
import { AdaptiveSwitch } from "adaptive-material-ui/components/switch";

export default function () {
  return (
    <AdaptiveModeDemo>
      <DemoList>
        <DemoListItem title="Color">
          <AdaptiveSwitch color="primary" defaultChecked />
          <AdaptiveSwitch color="secondary" defaultChecked />
          <AdaptiveSwitch color="error" defaultChecked />
          <AdaptiveSwitch color="info" defaultChecked />
          <AdaptiveSwitch color="success" defaultChecked />
          <AdaptiveSwitch color="warning" defaultChecked />
          <AdaptiveSwitch color="default" defaultChecked />
        </DemoListItem>
        <DemoListItem title="Size">
          <AdaptiveSwitch defaultChecked size="medium" />
          <AdaptiveSwitch defaultChecked size="small" />
        </DemoListItem>
        <DemoListItem title="Icon">
          <AdaptiveSwitch
            defaultChecked
            thumbIconChecked={<CheckIcon />}
            thumbIcon={<CloseIcon />}
          />
          <AdaptiveSwitch
            defaultChecked
            size="small"
            thumbIconChecked={<CheckIcon />}
            thumbIcon={<CloseIcon />}
          />
        </DemoListItem>
        <DemoListItem title="Disabled">
          <AdaptiveSwitch
            defaultChecked
            disabled
            thumbIconChecked={<CheckIcon />}
          />
          <AdaptiveSwitch disabled thumbIcon={<CloseIcon />} />
        </DemoListItem>
      </DemoList>
    </AdaptiveModeDemo>
  );
}

API

MUI Switch API with the following changes:

  • slotProps.thumb.children defaults to thumbIcon/thumbIconChecked
  • iOS: disableRipple defaults to true
  • Android: disableTouchRipple defaults to true

thumbIcon

Icon displayed inside the thumb when not checked

  • Type: ReactNode
  • Default: undefined

thumbIconChecked

Icon displayed inside the thumb when checked

  • Type: ReactNode
  • Default: undefined