"use client" import { Switch as AriaSwitch } from "react-aria-components" import { RegisterOptions, useController, useFormContext } from "react-hook-form" import styles from "./switch.module.css" import { MaterialIcon } from "../Icons/MaterialIcon" import { Typography } from "../Typography" interface SwitchProps extends React.InputHTMLAttributes { name: string registerOptions?: RegisterOptions } export default function Switch({ className, name, children, registerOptions, }: React.PropsWithChildren) { const { control } = useFormContext() const { field, fieldState } = useController({ control, name, rules: registerOptions, }) return ( {children} {fieldState.error ? (

{fieldState.error.message}

) : null}
) }