Modify the Material UI Autocomplete border color when hovered over

I'm attempting to modify the hover border color of the Autocomplete, which defaults to black. I have already attempted to override the .MuiAutocomplete-root class:

.MuiAutocomplete-root fieldset:hover{
    border-color: #2196F3;
}

However, it is still remaining black

Here is an example:

import React from "react";
import TextField from "@material-ui/core/TextField";
import Autocomplete from "@material-ui/lab/Autocomplete";

export default function ComboBox() {
  return (
    <Autocomplete
      id="combo-box-demo"
      options={top100Films}
      getOptionLabel={option => option.title}
      style={{ width: 300 }}
      renderInput={params => {
        return (
          <TextField
            {...params}
            label="Combo box"
            variant="outlined"
            fullWidth
          />
        );
      }}
    />
  );
}

const top100Films = [
  { title: "The Shawshank Redemption", year: 1994, },
  { title: "The Godfather", year: 1972, },
  { title: "Avatar", year: 2010, },
  // Plus a bunch more
];

CSS

.MuiAutocomplete-root div:first-of-type:hover{
    border-color: #2196F3;
}

Answer №1

Have you experimented with utilizing the !important override feature?

.MuiAutocomplete-root fieldset:hover{
   border-color: #2196F3 !important;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is there a way to resize an SVG coordinate system without altering the font size?

I am currently working on a data visualization project where I need to create an SVG graphic based on a specific data range. It would be ideal to use the viewBox attribute in order to scale the SVG so that the width of the graphic matches the width of the ...

Encountering an error while attempting to integrate react-router with react-transition-group: "Invalid element type specified..."

Currently, I am attempting to utilize the CSSTransition component from the react-transition-group module in order to create smooth page transitions when a user moves from one route to another. After running the code below, I encountered the following error ...

Batch script prematurely ends when compiling .less files in a batch for-loop

Recently, I decided to try my hand at using batch scripts as a way to compile the .less files for my website into .css files before deploying. It seemed like an efficient solution for my needs. However, after successfully utilizing a for loop in my batch ...

Utilizing effective CSS media queries within an Angular application

According to what I've read, it is not recommended in Angular to use the CSS hidden element to hide an element like this: .container{ background-color : powderblue; height : 50px; width : 100% } @media (max-width: 400px){ .container{ ...

The azure streak on the mobile dropdown menu

After successfully publishing my website using quarto with R, everything appears fine on desktop and mobile except for a minor issue with drop down menus on iPhone, showing blue lines when clicked. https://i.sstatic.net/xJRmU.jpg At the bottom of my .yml ...

HTML with embedded PHP script

i cannot seem to display mysql data in html format. the table i am working with is called App appid | app | version | date | apk file | 1 sample 1.0.0 2012-10-12 sample.apk //here is the mysql query ...

The type provided to React.createElement is not valid - it should be a string for built-in components or a class/function for composite components

Encountered an error while using a for loop. Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s%s, undefined, You likely forgot to export your compone ...

Issue with react-table: unable to display server-side data in table when implementing manual pagination, filtering, and sorting

I've encountered an issue trying to display data from the backend (Python API) in react-table manually. Despite going through the documentation, I'm struggling to implement the example provided here: The peculiar problem is that I can only see d ...

Adjust the size of bootstrap buttons based on the width of the screen

Is there a way to dynamically change the size and number of columns a bootstrap button spans based on the screen width? I have figured out how to adjust the number of columns, but changing the size (from btn-xs to btn-lg) is posing a challenge. Is it pos ...

What is the process for setting up both an open and closed status for my accordion?

After browsing through multiple threads on accordions, none seem to match my current structure which I believed was effective. In an attempt to learn and build elements from scratch, I created the following accordion with some help from Google and experi ...

Testing the Echarts react component using Jest, encountering an issue where EchartElement is returning as null

While performing a snapshot test on a component with multiple nested children components, one of which contains an Echart (bar-chart), the EchartElement is supposed to be set as the chart DOM element when rendered in a browser: <div class="echarts-for ...

Adjust divs for mobile display using Bootstrap and CSS

I have been struggling with rearranging two divs that are stacked vertically on mobile. I want the second div to appear above the first when the screen size is reduced. Despite trying various methods such as flexbox order and direction, I have not been suc ...

The React component is failing to display updated data from the Redux store

I've been working with React and Redux, trying to update my counter value in the React view. I can successfully log the latest state of my Redux store, but the changes are not reflecting in my React view. const counter = (state = 0, action) => { ...

Retrieve the attribute from the containing div element

I have nested div elements and I am trying to access the attribute food from the outermost div through the innermost div. How can I achieve this? In the code, I am attempting to display an alert with the value 'banana'. //alert($('.anima ...

troubleshooting problems with jquery loading animations

My goal is to hide the menu, display an animated gif, hide the gif, and then show the updated menu. However, even though the menu disappears and reappears, the animated gif refuses to be shown. Where could I be making a mistake? $(document).ready(functio ...

Instructions for activating the click function for each individual looping image

When creating a blog page, I am using PHP to loop the like button images according to the total count of posts (example: Facebook like button). The issue I am facing is that while the PHP loop is working, when I click on the first post image, only the firs ...

Guide to "flashing" an image momentarily on the screen using PHP

I'm looking for a way to display an image on my simple website for 3 seconds and then prompt the user to indicate if they recognized the image or not by clicking a button. I don't need help with the button, just how to create the timer. While I ...

Tips for incorporating clickable messages from PrimeReact into your React application

Currently, I am attempting to replicate the functionality demonstrated in this example, which showcases clickable messages from the PrimeReact components library. However, I have encountered a variable named messages within the code that I am unsure of its ...

I am looking to enable the selection of multiple buttons within a List group

I'm facing an issue with my code where the dropdown menu is not displaying dropdown items. I need help fixing this problem, it would be greatly appreciated. Additionally, I also want to enable multiple selection of buttons and change the color of each ...

Encountering the "Path not found" error message when trying to create a new React app

Here is the error message that occurred: Aborting installation. npm install --save --save-exact --loglevel error react react-dom react-scripts has failed. Deleting generated file... node_modules Deleting generated file... package.json Deleting first ...