Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override Theme for MUI DatePicker Pro

Tags:

material-ui

I am trying to add CSS changes to my theme for MUIX components and it seems like I am getting type errors. For this example we will use for DatePicker Component. According to the docs I should be able to do the following:

import { create theme, ThemeOptions } from ‘@mui/material/styles’;

const MyTheme: ThemeOptions = createTheme({
  components: {
    MuiPickersToolbar: {
      …
    }
  }
})

But the MuiPickersToolbar lights up red with a type error:

Object literal may only specify known properties, and `MuiPickersToolbar` does not exist in type ‘Components<Omit<Theme, “components”>>’

In my package.json I have the following peerDependencies

“@emotion/react”: “>=11.11.3”,
“@mui/material”: “>=5.15.7”,
“@mui/x-date-pickers-pro”: “>=6.19.3”

Not sure what I am missing here

like image 284
jrock2004 Avatar asked Nov 05 '25 16:11

jrock2004


1 Answers

You need to add the following import:

import type {} from '@mui/x-date-pickers-pro/themeAugmentation';

You can find the documentation about this here:

https://mui.com/x/react-date-pickers/base-concepts/#typescript

Related answer: Fix Typescript error when customizing MuiDataGrid in createTheme

like image 50
Ryan Cogswell Avatar answered Nov 07 '25 14:11

Ryan Cogswell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!