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

757
Views
Material ui - datepicker does not change the style when focus

This is my current datepicker.
enter image description here

I want to add the box-shadow when I the textfield is focus like below
enter image description here

I tried to add it using makeStyles but not working

demo.js

import "date-fns";
import React from "react";
import DateFnsUtils from "@date-io/date-fns";
import {
  MuiPickersUtilsProvider,
  KeyboardTimePicker
} from "@material-ui/pickers";

import { makeStyles } from "@material-ui/core/styles";

export const styles = makeStyles(() => ({
  root: {
    marginTop: 0,
    "& .MuiInputBase-root": {
      border: "1px solid grey",
      borderRadius: "0.25rem",
      padding: "0.375rem 0.75rem",
      "&:focus": { //added here
        borderColor: "#86b7f",
        boxShadow: "0 0 0 0.25rem red"
      },
      "&:before": {
        borderBottom: "none"
      },
      "&:after": {
        borderBottom: "none"
      },
      "&:hover:hover:not(.Mui-disabled):before": {
        borderBottom: "none"
      },
      "& .MuiButtonBase-root": {
        padding: 0
      }
    }
  }
}));

export default function MaterialUIPickers() {
  const classes = styles();
  const [selectedDate, setSelectedDate] = React.useState(
    new Date("2014-08-18T21:11:54")
  );

  const handleDateChange = (date) => {
    setSelectedDate(date);
  };

  return (
    <>
      <MuiPickersUtilsProvider utils={DateFnsUtils}>
        <KeyboardTimePicker
          margin="normal"
          id="time-picker"
          value={selectedDate}
          onChange={handleDateChange}
          KeyboardButtonProps={{
            "aria-label": "change time"
          }}
          className={classes.root}
        />
      </MuiPickersUtilsProvider>
    </>
  );
}

CodeSandbox:
https://codesandbox.io/s/material-demo-forked-b6z4b?file=/demo.js:0-1460

about 4 years ago · Juan Pablo Isaza
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!