Hero Hook Form API / SwitchFieldProps
Type Alias: SwitchFieldProps<TFieldValues>
SwitchFieldProps<
TFieldValues> =FieldBaseProps<TFieldValues,boolean> &WithControl<TFieldValues> &object
Defined in: fields/SwitchField.tsx:35
Props for the SwitchField component.
Type Declaration
switchProps?
optionalswitchProps:Omit<React.ComponentProps<typeofSwitch>,"isSelected"|"onValueChange"|"isInvalid"|"isDisabled">
Additional props to pass to the underlying Switch component
Type Parameters
TFieldValues
TFieldValues extends FieldValues
The form data type
Example
import { SwitchField } from "@rachelallyson/hero-hook-form";
import { useForm } from "react-hook-form";
const form = useForm({
defaultValues: { notifications: false },
});
<SwitchField
control={form.control}
name="notifications"
label="Enable notifications"
description="Receive email notifications"
/>