MCPcopy Create free account
hub / github.com/Superflows-AI/superflows / Toggle

Function Toggle

components/toggle.tsx:4–35  ·  view source on GitHub ↗
(props: {
  enabled: boolean;
  setEnabled: (enabled: boolean) => void;
  size: "sm" | "md";
  sr?: string;
})

Source from the content-addressed store, hash-verified

2import classNames from "classnames";
3
4export default function Toggle(props: {
5 enabled: boolean;
6 setEnabled: (enabled: boolean) => void;
7 size: "sm" | "md";
8 sr?: string;
9}) {
10 return (
11 <Switch
12 checked={props.enabled}
13 onChange={props.setEnabled}
14 className={classNames(
15 props.enabled ? "bg-purple-600" : "bg-gray-300",
16 "relative inline-flex flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none",
17 props.size === "sm" ? "h-5 w-9" : "h-6 w-11",
18 )}
19 >
20 {props.sr && <span className="sr-only">{props.sr}</span>}
21 <span
22 aria-hidden="true"
23 className={classNames(
24 props.enabled
25 ? props.size === "sm"
26 ? "translate-x-4"
27 : "translate-x-5"
28 : "translate-x-0",
29 "pointer-events-none inline-block transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out",
30 props.size === "sm" ? "h-4 w-4" : "h-5 w-5",
31 )}
32 />
33 </Switch>
34 );
35}

Callers

nothing calls this directly

Calls 1

classNamesFunction · 0.85

Tested by

no test coverage detected