Skip to content
+

Custom field

The Date and Time Pickers let you customize the field by passing props or custom components.

Customize the default field

Customize the TextField

You can use the textField slot to pass custom props to the TextField:

MM/DD/YYYY
MM/DD/YYYY

Please fill this field

MM/DD/YYYY
Press Enter to start editing

Customize the separator of multi input range fields

You can use the fieldSeparator slot to pass custom props to the Typography rendered between the two TextField:

MM/DD/YYYY

MM/DD/YYYY
MM/DD/YYYY

MM/DD/YYYY
Press Enter to start editing

Customize the start and end fields differently

You can pass conditional props to the textField slot to customize the input styling based on the position.

04/17/2022

MM/DD/YYYY
Press Enter to start editing

Use single input fields on range pickers

You can pass the single input fields to the range picker to use it for keyboard editing:

MM/DD/YYYYMM/DD/YYYY
Press Enter to start editing

If you want to create a wrapper around the field, make sure to set the fieldType static property to 'single-input'. Otherwise, the picker won't know your field is a single input one and use the multi input event listeners:

MM/DD/YYYYMM/DD/YYYY

You can manually add an endAdornment if you want your range picker to look exactly like on a simple picker:

MM/DD/YYYYMM/DD/YYYY
Press Enter to start editing

Change the separator of range fields

You can use the dateSeparator prop to change the separator rendered between the start and end dates:

MM/DD/YYYY

to

MM/DD/YYYY
MM/DD/YYYY to MM/DD/YYYY
Press Enter to start editing

Change the format density

You can control the field format spacing using the formatDensity prop. Setting formatDensity to "spacious" will add a space before and after each /, - and . character.

04/17/2022
04/17/2022
04 / 17 / 2022
Press Enter to start editing

With Material UI

Wrapping PickersTextField

You can import the PickersTextField component to create custom wrappers:

MM/DD/YYYY
MM/DD/YYYY
Press Enter to start editing

Using Material TextField

Pass the enableAccessibleFieldDOMStructure={false} to any Field or Picker component to use an <input /> for the editing instead of the new accessible DOM structure:

Press Enter to start editing

With another Design System

Using a custom input

MM/DD/YYYY
MM/DD/YYYYMM/DD/YYYY
MM/DD/YYYY
MM/DD/YYYY

Using Joy UI

You can use the Joy UI components instead of the Material UI ones:

With a custom editing experience

Using an Autocomplete

If your user can only select a value in a small list of available dates, you can replace the field with the Autocomplete component to list those dates:

Using a masked Text Field

If you want to use a simple mask approach for the field editing instead of the built-in logic, you can replace the default field with the TextField component using a masked input value built with the rifm package.

Using a read-only Text Field

If you want users to select a value exclusively through the views but you still want the UI to look like a Text Field, you can replace the field with a read-only Text Field component:

Using a Button

If you want users to select a value exclusively through the views and you don't want the UI to look like a Text Field, you can replace the field with the Button component:

The same logic can be applied to any Range Picker:

API

See the documentation below for a complete reference to all of the props and classes available to the components mentioned here.