Single date input with an optional “Include Time” toggle. Under the hood it uses:
Value type: Date | null.
import { useForm } from 'react-hook-form';
import { Form } from 'semantic-ui-react';
import { HookFormDatePicker } from '@karmaniverous/hook-form-semantic';
type FormData = { publishAt: Date | null };
export function PublishScheduler() {
const { control, handleSubmit, watch } = useForm<FormData>({
defaultValues: { publishAt: null },
});
const when = watch('publishAt');
return (
<Form onSubmit={handleSubmit(console.log)}>
<HookFormDatePicker<FormData>
hookControl={control}
hookName="publishAt"
label="Publish at"
/>
<div style={{ marginTop: 8, fontSize: 12 }}>
Current value: {when ? when.toISOString() : 'unset'}
</div>
<Form.Button primary style={{ marginTop: 12 }}>
Schedule
</Form.Button>
</Form>
);
}
Props
datePicker* → forwarded to react-date-pickertimePicker* → forwarded to react-datetime-pickerhook* (e.g., hookControl, hookName, hookRules).Notes
Date | null.hookRules (e.g., must be in the future).