MUI 5 disable year change in MobileDatePicker

Viewed 15

I want to disable the ability to change the year in the mobile date picker I am using

import { LocalizationProvider, MobileDatePicker } from '@mui/x-date-pickers';

I am on

"@mui/x-date-pickers": "^5.0.0-beta.7",

mobile date picker

I don't want the user to be able to go into this view change year view

I don't see a setting to turn this off does anyone know if there is a prop to set to disable this setting.

1 Answers

You just have to add the prop views with an object, where you can put {['day']} or {['day', 'month']}

<LocalizationProvider adapterLocale={es} dateAdapter={AdapterDateFns}>
  <DatePicker
    inputFormat="dd"
    value={value}
    onChange={handleChange}
    renderInput={(params) => <TextField {...params} />}
    views={['day']}
  />
</LocalizationProvider>

Here's the documentation

Related