Skip to main content

RHFTimePicker

RHFTimePicker extends the TimePicker component to allow users to select time for an event.

info

RHFTimePicker uses uses dayjs as its default adapter. To switch to a different date adapter, please refer the customization guide.

Usage

import { RHFTimePicker, RHFTimePickerProps } from '@nish1896/rhf-mui-components';
<RHFTimePicker
fieldName="wakeUpTime"
register={register}
setValue={setValue}
errorMessage={errors?.wakeUpTime?.message}
/>

Examples

API

RHFTimePickerProps extends TimePickerProps and accepts the following additional props:

NameTypeRequiredDescription
fieldNamestringReact Hook Form requires name as a key for the registration process.
registerUseFormRegisterThe register option yielded on calling the useForm hook.
registerOptionsRegisterOptionsRegister options if using react-hook-form without any validation libraries like yup or Joi.
setValue(name: string, value: unknown, config?: Object) => voidThe setValue option yielded on calling the useForm hook.
onValueChange(newValue: unknown) => voidAn optional callback function which returns the selected date or time value.
showLabelAboveFormFieldbooleanRender form label above the form field in FormLabel component.
formLabelPropsFormLabelPropsFormLabelProps to customise FormLabel component for a field. Multiple fields can be configured using the ConfigProvider component.
helperTextReactNodeOptional helperText to render under RHFSelect or RHFNativeSelect field.
errorMessageReactNodeError message to be shown for a field in FormHelperText component.
hideErrorMessagebooleanPrevent replacing of form HelperText by error message during validation trigger.
formHelperTextPropsFormHelperTextPropsFormHelperTextProps to customise FormHelperText component for a field. Multiple fields can be configured using the ConfigProvider component.