MUI Components
NPM

Date Pickers

These components wrap the Material UI X Date Picker with the suite's label, error and helper-text handling.

Use a date picker when you need a calendar day without a time, such as a date of birth, a check-in date or an invoice due date. The value is a date object from your date library, so you can compare it with other dates, limit it with minDate and maxDate, or format it however your API expects.

Each date picker comes in four variants:

  • MUIDatePicker — responsive (renders the desktop UI on pointer devices, the mobile UI on touch).
  • MUIDesktopDatePicker — always renders the desktop (keyboard-first) UI.
  • MUIMobileDatePicker — always renders the mobile (modal) UI.
  • MUIStaticDatePicker — an always-visible inline picker with no text field.

All of these share the same controlled contract — a value in your datelibrary's format and an onValueChange callback.

Setup

All pickers read their date adapter from ConfigProvider. Wrap your app once and pass the adapter for your date library (Day.js, Luxon, date-fns or Moment).

import { ConfigProvider } from '@nish1896/mui-components/config';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';

<ConfigProvider dateAdapter={AdapterDayjs}>
  <App />
</ConfigProvider>
Warning

Without a dateAdapter, the pickers throw an error at render — this is the one required piece of setup.

Usage

import { MUIDatePicker } from '@nish1896/mui-components/mui-pickers/date';
import { type Dayjs } from 'dayjs';
const [value, setValue] = useState<Dayjs | null>(null);

<MUIDatePicker
  fieldName="date"
  value={value}
  onValueChange={({ newValue, context }) => setValue(newValue)}
/>

value uses the date type of your date adapter, such as a Dayjs for AdapterDayjs, and null or undefined clears the picker. newValue has the same type, inferred from the value you pass. onValueChange receives { newValue, context } and is called for every change, including entries that aren't valid dates, so check context.validationError before relying on newValue.

Other variants

The other three variants are exported from the same module and take the same props. Use MUIDesktopDatePicker for the keyboard-first popover on every device, MUIMobileDatePicker for a modal dialog, and MUIStaticDatePicker for an always-visible calendar without a text field (see the note below the API table).

import {
  MUIDesktopDatePicker,
  MUIMobileDatePicker,
  MUIStaticDatePicker
} from '@nish1896/mui-components/mui-pickers/date';

<MUIMobileDatePicker
  fieldName="appointment"
  value={value}
  onValueChange={({ newValue }) => setValue(newValue)}
/>

onAccept is passed through to MUI X and fires when the user finishes picking a value.

Validation and date limits

Limit the selectable dates with the MUI X props minDate, maxDate, disablePast, disableFuture and shouldDisableDate. Disabled days can't be picked in the calendar, and a typed date outside the limits is reported through context.validationError. It is one of 'invalidDate', 'minDate', 'maxDate', 'disablePast', 'disableFuture', 'shouldDisableDate', 'shouldDisableMonth' or 'shouldDisableYear', and null when the value is valid. Map it to your own errorMessage.

import dayjs, { type Dayjs } from 'dayjs';

const messages: Record<string, string> = {
  invalidDate: 'Enter a valid date',
  minDate: 'The date is too early',
  maxDate: 'The date is too far ahead'
};

const [value, setValue] = useState<Dayjs | null>(null);
const [error, setError] = useState<string>();

<MUIDatePicker
  fieldName="travelDate"
  value={value}
  onValueChange={({ newValue, context }) => {
    setValue(newValue);
    setError(context.validationError ? messages[context.validationError] : undefined);
  }}
  minDate={dayjs()}
  maxDate={dayjs().add(1, 'year')}
  errorMessage={error}
/>

Customizing the input

format sets how the date is written in the field, using the tokens of your date library, such as 'DD/MM/YYYY' for Day.js. slotProps.textField is forwarded to the text field, as an object or a function, for props like size and fullWidth. The component controls the text field's id, error and ARIA attributes.

<MUIDatePicker
  fieldName="dob"
  value={dob}
  onValueChange={({ newValue }) => setDob(newValue)}
  format="DD/MM/YYYY"
  slotProps={{ textField: { size: 'small', fullWidth: true } }}
/>

API

All four variants (MUIDatePicker, MUIDesktopDatePicker, MUIMobileDatePicker, MUIStaticDatePicker) share the props below.

Props marked with * are required.

NameTypeDescription
fieldName*string
Name/path of the field. Used to derive the id, the default label, and the name attribute. This prop is required for all components.
valuePickerValidDate | null
Current picker value in the configured date library format. Pass null or undefined to clear the picker.
onValueChange*({ newValue, context }) => void
Called after the picker accepts a valid date value. context.validationError reports the MUI X validation status.
requiredboolean
Indicates that the field is mandatory by adding an asterisk symbol (*) to the form label and setting the relevant accessibility attributes.
labelReactNode
Label displayed for the field. Defaults to a human-readable label derived from fieldName, e.g. firstName becomes "First Name".
showLabelAboveFormFieldboolean
When true, renders the field label above the form field in the FormLabel component, instead of inside or beside it. Takes precedence over allLabelsAboveFields from the ConfigProvider, so false keeps the label inside this field even when the config places every label above its field.
formLabelPropsFormLabelProps
FormLabelProps forwarded to the internal FormLabel. The id is managed by the component. Multiple fields can be configured using the ConfigProvider component.
hideLabelboolean
When true, hides the rendered field label while preserving accessible labeling where possible.
errorMessagestring | string[]
Validation error for the field — pass a single message string, or a string[] when the field can fail multiple rules at once (every message is shown together). A non-empty string or array puts the field in an error state; undefined/''/[] clear it.
Normalize your form library's error shape to this at the call site (e.g. an RHF FieldError via its .message). Use renderError to customize how the message(s) are rendered.
renderError(errors: string[]) => ReactNode
Custom renderer for the resolved error message(s), called only when the field is in an error state. Always receives a string[] — use errors[0] for the common single-message case, or map over errors when a field fails several rules. By default a single message renders as text and multiple messages render on separate lines.
hideErrorMessageboolean
If true, hides the error message text while keeping the field in an error state.
helperTextReactNode
Content displayed in the FormHelperText component below the field when there is no visible validation error.
formHelperTextPropsFormHelperTextProps
FormHelperTextProps forwarded to the internal FormHelperText. The id is managed by the component. Multiple fields can be configured using the ConfigProvider component.
slotPropsobject
MUI X picker slotProps. The textField slot is merged with the component's own id, error state, and aria attributes.
customIds{ field, label, helperText, error }
Overrides the default field, label, helper text, and error IDs used for accessibility.
Info

MUIStaticDatePicker renders inline with no text field, so two props behave slightly differently: fieldName only derives the generated ids and default label (no name attribute, since there's no input), and showLabelAboveFormField defaults to false — with no built-in inline label, that means no visible label renders at all (the accessible name is still applied).

Playground

Date Pickers

MUIDatePicker — responsive, disableFuture

MM/DD/YYYY

MUIDesktopDatePicker — always the keyboard-first UI

DD MMMM YYYY

MUIMobileDatePicker — always the modal UI

MM/DD/YYYY

MUIStaticDatePicker — always-visible inline, no text field

Select date

––

October 2026
SMTWTFS

Form State - Values & Errors

Source Code

View the full implementation of this component on GitHub.