0

I'm creating a custom component with custom styles using KeyboardDatePicker from @material-ui/pickers.

I need to customize the labels. I know that I can use getWeekdays based on https://material-ui-pickers.dev/guides/formats and using MuiPickersUtilsProvider. But in order to do so, I need to extend from a DateUtil (moment, datefns, etc).

class CustomDateUtil extends MomentUtils // or any other util {
   getWeekdays() {
     ...
   }
}

and then

<MuiPickersUtilsProvider utils={CustomDateUtil}>
  ....
</MuiPickersUtilsProvider>

What I want to accomplish is the label renaming without the need of depending on a specific DateUtil. It's like doing this but in a generic way, for all DateUtils.

Jeremy410
  • 41
  • 1
  • 7
  • Are you using multiple different dateUtils in one project? It's pretty standard to put the ThemeProvider and MuiPickersUtilsProvider at the top level component in your project and only have one of them, because at least in older versions of MUI, having multiple nested themes caused some whacky behavior – katamaster818 Oct 22 '20 at 20:02
  • is a monorepo, im building a component which should work with any dateUtil the consumer want. That the issue, i will like to be able to take whatever dateutil is being used and apply the override method – Jeremy410 Oct 22 '20 at 20:42
  • Maybe I'm misunderstanding the question, but is there some reason why you can't just use the format prop on the KeyboardDatePicker – katamaster818 Oct 22 '20 at 22:33
  • @katamaster818 what do you mean by KeyboardDatePicker format? I'm trying to rename the labels of the calendar. As far as I know, there is not a prop available in order to do that. – Jeremy410 Oct 23 '20 at 13:46

0 Answers0