How to change mui textfield border color on hover in react js?

Hi Friends 👋,

Welcome To aGuideHub! ❤️

To change the border color on hover in mui textfield, you have to use mui material styles, which we can define on hover in mui textfield.

Today, I am going to show you. how to change mui textfield border color on hover in react js mui text field.

const CssTextField = styled(TextField)({
  '& .MuiOutlinedInput-root': {
    '&:hover fieldset': {
      borderColor: 'yellow',


Install the following packages to use mui text field in react js.


npm install @mui/material @emotion/react @emotion/styled


yarn add @mui/material @emotion/react @emotion/styled

MUI material text field change border color on hover example

To change the border color on hover, the class .& .MuiOutlinedInput-root has to be used.


import * as React from 'react';
import { styled } from '@mui/material/styles';
import Box from '@mui/material/Box';
import TextField from '@mui/material/TextField';

const CssTextField = styled(TextField)({
  '& label.Mui-focused': {
    color: 'green',
  '& .MuiInput-underline:after': {
    borderBottomColor: 'green',
  '& .MuiOutlinedInput-root': {
    '& fieldset': {
      borderColor: 'red',
    '&:hover fieldset': {
      borderColor: 'yellow',
    '&.Mui-focused fieldset': {
      borderColor: 'green',

export default function CustomizedInputs() {
  return (
        display: 'grid',
        gridTemplateColumns: { sm: '1fr 1fr' },
        gap: 2,
      <CssTextField label="Custom CSS" id="custom-css-outlined-input" />

In the above code example, I have used the @mui/material TextField component and changed the border color on the hover of all types of MUI Textfield.

Check the output of the above code example.

React, Mui Textfield Border Color on Hover

All the best 👍 🤝

Premium Content

You can get all the below premium content directly in your mail when you subscribe us


Portfolio Template

View | Get Source Code

Cheat Sheets

Cheat Sheets Books are basically Important useful notes which we use in our day-to-day life.

I'm working on some more Cheat Sheets book on Jquery, TypeScript, React js and for other languages. I will send it once it's completed.

Related Posts