Ask Your Question
4

What is the method for arranging years in reverse order within the material-ui Date Picker's calendar UI?

asked 2022-11-23 11:00:00 +0000

nofretete gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2022-03-31 22:00:00 +0000

lakamha gravatar image

To arrange years in reverse order within the material-ui Date Picker's calendar UI, you can pass a start year and end year to the DatePicker component and set the shouldDisableYear prop function to return false for all the years within the range. Here's an example:

const startYear = 1950;
const endYear = 2021;

function shouldDisableYear(year) {
  return year < startYear || year > endYear;
}

<DatePicker
  label="Pick a date"
  views={['year', 'month', 'date']}
  shouldDisableYear={shouldDisableYear}
  minDate={new Date(startYear, 0, 1)}
  maxDate={new Date(endYear, 11, 31)}
/>

This will enable only the years within the range and display them in reverse order within the calendar UI.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-11-23 11:00:00 +0000

Seen: 13 times

Last updated: Mar 31 '22