Switch
A switch is a binary switch.
Overview
Copy
import { FormField } from "@camome/core/FormField";import { Switch } from "@camome/core/Switch";
export default function Default() { return ( <FormField label="Label" description="Description text" error="This is an error" custom > <div style={{ display: "flex", gap: "2rem", alignItems: "center" }}> <div style={{ display: "flex", flexDirection: "column", gap: "0.3rem" }} > <FormField.Label /> <FormField.Description /> </div> <Switch size="md" on="ON" off="OFF" /> </div> </FormField> );}
Size
Copy
import { FormField } from "@camome/core/FormField";import { Switch } from "@camome/core/Switch";
import styles from "./styles.module.scss";
export default function Size() { return ( <div className={styles.size__container}> <FormField label="Small"> <Switch size="sm" on="ON" off="OFF" /> </FormField> <FormField label="Medium"> <Switch size="md" on="ON" off="OFF" /> </FormField> <FormField label="Large"> <Switch size="lg" on="ON" off="OFF" /> </FormField> </div> );}
With icons
Copy
import { MoonIcon, SunIcon } from "@heroicons/react/24/outline";
import { Switch } from "@camome/core/Switch";
export default function Default() { return ( <Switch size="lg" on={<SunIcon width="1.2rem" height="1.2rem" strokeWidth={2.5} />} off={<MoonIcon width="1.2rem" height="1.2rem" strokeWidth={2.5} />} aria-label="Switch" /> );}