Is there any way to implement a month Picker and year picker using material UI. In month view the output should be like only month and the year only Eg:- 2020-09
5
votes
2 Answers
3
votes
You can use different views as demonstrated in this section here.
<DatePicker
variant="inline"
openTo="year"
views={["year", "month"]}
label="Year and Month"
helperText="Start from year selection"
value={selectedDate}
onChange={handleDateChange}
/>
Live Demo
2
votes
In your component, pass an array called views
with month
and year
.
views={["year", "month"]}
Take a look at views
prop for more info: https://material-ui-pickers.dev/api/KeyboardDatePicker
Also change the format
to MM/yyyy
format="MM/yyyy"
Here is a sandbox for your reference: