RHF-MUI Components
NPM

RHFDateTimePicker

RHFDateTimePicker extends DateTimePicker component, allowing users to select a date and time for an event.

Starting with version 4, this module also exports RHFDesktopDateTimePicker, RHFMobileDateTimePicker, and RHFStaticDateTimePicker.

Usage

import {
  RHFDateTimePicker,
  RHFDesktopDateTimePicker,
  RHFMobileDateTimePicker,
  RHFStaticDateTimePicker,
  type RHFDateTimePickerProps,
  type RHFDesktopDateTimePickerProps,
  type RHFMobileDateTimePickerProps,
  type RHFStaticDateTimePickerProps
} from '@nish1896/rhf-mui-components/mui-pickers/date-time';
<RHFDateTimePicker
  fieldName="meetingDateTime"
  control={control}
/>

Examples

API

RHFDateTimePickerProps extends DateTimePickerProps and accepts the following additional props. Props marked with * are required.

NameTypeDescription
fieldName*string
Name of the field registered with React Hook Form. This prop is required for all components.
control*UseFormControl
The control option yielded on calling the useForm hook.
registerOptionsRegisterOptions
React Hook Form validation rules. Useful when not using a schema validation library such as Yup or Joi.
requiredboolean
Indicates that the field is mandatory by adding an asterisk symbol (*) to the formLabel. This visual cue helps users quickly identify required fields in the form.
customOnChange({ rhfOnChange, newValue, context }) => void
Custom change handler that overrides the default date and time value update behavior. Receives rhfOnChange, the updated value, and the MUI picker change context. When provided, you must call rhfOnChange manually to update the form value.
onValueChange({ newValue, context }) => void
Optional callback fired when the selected date and time changes and the picker value is valid. Receives the updated value and the MUI picker change context.
labelReactNode
The text to render in the FormLabel component. By default, the value of fieldName is transformed (e.g., "firstName" to "First Name") using the fieldNameToLabel function.
showLabelAboveFormFieldboolean
Render form label above the form field in FormLabel component.
formLabelPropsFormLabelProps
FormLabelProps to customise FormLabel component for a field. Multiple fields can be configured using the ConfigProvider component.
hideLabelboolean
Hides the FormLabel component if you don’t want to display the default form label component or prefer to render a fully custom label instead.
renderError(error: FieldError) => ReactNode
Custom renderer for the React Hook Form field error. Receives the current field error and returns the content to display, such as error.message or a custom React element in the HelperText component.
Added in v4.1.0.
hideErrorMessageboolean
A flag to prevent replacement of helper text of a field by the errorMessage when the validation is triggered.
helperTextReactNode
The content to display within the FormHelperText component below the field. If the field validation fails, this content will be overridden by the corresponding error message.
formHelperTextPropsFormHelperTextProps
FormHelperTextProps to customise FormHelperText component for a field. Multiple fields can be configured using the ConfigProvider component.
customIds{ field, label, helperText, error }
Overrides the default field, label, helper text, and error IDs used for accessibility.

Source Code

View the full implementation of this component on GitHub.