Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

346
Views
Changing the Material UI's DatePicker's border color

enter image description here

This is my DatePicker from material UI, the only thing I want is to change borderColor. I've tried classes, changing the theme's primary color, using WithStyles.. Nothing seems to work.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

The className prop is not applied to the MUI DatePicker component currently. There is an open issue on GitHub for this bug.

Alternatively, you can pass className prop to renderInput prop like:

<DatePicker
    label="Birthdate"
    defaultValue={new Date()}
    renderInput={(params) => (
      <TextField {...params} className="myDatePicker" />
    )}
/>

and apply the css on fieldset tag like:

.myDatePicker fieldset.MuiOutlinedInput-notchedOutline {
  border-color: green;
}

.myDatePicker .Mui-focused fieldset.MuiOutlinedInput-notchedOutline {
  border-color: red;
}

You can take a look at this sandbox for a live working example of this usage.

about 4 years ago · Juan Pablo Isaza Report

0

Here is a way to customise the default, hover and active styling for the border color. You can also do the same using styled components. Here is a working codesandbox.

<DatePicker
        label="Birthdate"
        defaultValue={new Date()}
        renderInput={(params) => (
          <TextField
            {...params}
            sx={{
              '& .MuiOutlinedInput-root': {
                '& fieldset': {
                  borderColor: 'red',
                },
                '&:hover fieldset': {
                  borderColor: 'green',
                },
                '&.Mui-focused fieldset': {
                  borderColor: 'purple',
                },
              },
            }}
          />
        )}
      />
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!