Controlled checkbox wired to RHF with extra niceties:
Form.Field
.Value type: boolean
.
import { useForm } from 'react-hook-form';
import { Form } from 'semantic-ui-react';
import { HookFormCheckbox } from '@karmaniverous/hook-form-semantic';
type FormData = { featureEnabled: boolean };
export function FeatureToggle() {
const { control, handleSubmit } = useForm<FormData>({
defaultValues: { featureEnabled: false },
});
return (
<Form onSubmit={handleSubmit(console.log)}>
<HookFormCheckbox<FormData>
hookControl={control}
hookName="featureEnabled"
label="Feature"
leftLabel="Beta"
uncheckLabel="Disable"
checkLabel="Enable"
rightLabel="(experimental)"
/>
<Form.Button primary>Apply</Form.Button>
</Form>
);
}
Notes
hookRules
for required/conditional logic if needed (e.g., “must be true”).