Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Change Text in StaticDateTimePicker MUI

i want to change the title text of the component StaticDateTimePicker
what to replace

in the DOM he is
enter image description here

following the API documentation, I realized that I need to refer to components: Toolbar and use custom,
enter image description here
enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I found the default toolbar, (import {DateTimePickerToolbar} from "@mui/x-date-pickers";)
but I don’t know how to change this component in it

>Solution :

What you need is a Localization in Material UI to replace the text: https://mui.com/x/react-date-pickers/localization/

The key to replace is called as dateTimePickerToolbarTitle (Reference: https://github.com/mui/mui-x/blob/e4a23755d6f0516ab1ca1a7237e51db9d765343e/packages/x-date-pickers/src/locales/enUS.ts#L31)

To override your specific case:

<StaticDateTimePicker localeText={{ dateTimePickerToolbarTitle: 'Your Text Here' }} />
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading