Modifying the Button component does not affect the hover color

I'm currently attempting to modify the color of all the buttons in my project by overriding the theme CSS. Although I successfully changed the button color, the hover color remains transparent. Any suggestions on how to override this?

Are there any alternative methods to achieve this without having to add a class to each individual button?

Additionally, shouldn't all variations of a button adhere to the root CSS?

const theme = createMuiTheme({
  palette: {
    primary: {
      light: '#35C37D',
      main: '#35C37D',
      dark: '#35C37D',
      // contrastText: will be calculated to contrast with palette.primary.main
    },
    secondary: {
      light: '#35C37D',
      main: '#35C37D',
      // dark: will be calculated from palette.secondary.main,
      contrastText: '#35C37D',
    },
    // error: will use the default color
  },
  overrides: {
    MuiButton: {
      // Name of the rule
      root: {
        // Some CSS
        background: 'rgba(53, 195, 125, 100)',
        borderRadius: 0,
        border: 0,
        colorInherit: '#fff',
        color: 'white',
        height: 40,
        padding: '0 30px',
        boxShadow: '4px 9px 26px 0 rgba(16,124,71,0.10)'
      },
      textPrimary: {
        color: '#fff',
      },
      textSecondary: {
        color: '#fff',
      },
      contained: {
        color: '#fff',
      },

      // Additional button variation styles
      
    },
  },
  typography: {
    fontFamily: 'azo-sans-web',
    fontSize: 14, 
    fontWeightLight: 300,
    fontWeightRegular: 400,
    fontWeightMedium: 500,
    htmlFontSize: 16,
  },
});

Answer №1

I finally got it all figured out. If anyone is interested, you can check out the code sandbox https://codesandbox.io/s/y2qyk9rn4x

All you have to do is include this snippet for each variant:

outlined: {
  "&:hover": {
    backgroundColor: "#35C37D"
  }
},

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

Encountering issues during the npm installation process, with numerous warnings eventually leading

I encountered an issue with my ReactJS project that was working perfectly fine up until last week. Starting from Sunday, I started receiving the following error when trying to run npm install: PS C:\Projects\Interface\ClientApp> npm insta ...

Use JavaScript to dynamically change the value of an HTML input field based on the contents of a <li> list item

On my HTML page, I am dynamically creating <li> elements using an Autocomplete API. As you type in the input box, the API suggests the Website logo, website name, and website URL within the <li> elements. Currently, this functionality is workin ...

What could be causing the abundance of API calls from Yandex Metrica?

In my Nextjs SPA, there is an iframe widget that is rendered using React. Inside this widget's index.html file, I have inserted the Yandex Metrica script and set up a goal tag to track user clicks on the registration button. The goal tracking is wor ...

503 error received despite specified CORS settings blocking Axios request

After trying numerous solutions to fix a CORS problem (47 to be exact), I am starting to suspect that the issue might not be with CORS itself, but with how my axios request is configured. Could it be possible that the problem lies in my axios setup rather ...

CSS can only fade out without hiding afterwards

I'm struggling to create a CSS class and animation that will fade out or move a div along with its contents, resulting in the div having both display:none and visibility:hidden My attempts so far have been unsuccessful! I can either get the animation ...

Center align the division within the list item

Check out the fiddle provided here: https://jsfiddle.net/5jnnutg8/ I am looking for a way to center align and display inline the "something #" list items. While the title "Hi" can be centered using text-align: center in css, this doesn't seem to wor ...

Access to the XMLHttpRequest from the origin http://localhost:3000 has been restricted by the Cross-Origin Resource Sharing (CORS)

I've successfully set up both the front and backend for an app I am currently developing. Now, I need to test the HTTP requests being sent from the front end to the backend while they are running on localhost. Here's the code snippet for sending ...

Is there a way to ensure that the animation does not stop until it reaches the final frame when the pointer leaves?

My challenge lies in ensuring that an animation triggered by hovering over an element continues to play until it reaches its final frame, even after the mouse pointer leaves the element. How can I make this happen? <mesh name="rond-ui-item-01 ...

Overflow of Div Content

I need a way to showcase a collection of around 30 links in a horizontal layout without the links wrapping to a new line if they exceed the width of the parent container. A horizontal scroll should appear for users to navigate through the overflowing links ...

Identify the CSS Framework being used in conjunction with Selenium

I have developed a program that crawls through various web pages and conducts tests using Selenium. My current task is to identify which CSS Frameworks are utilized on these websites for statistical analysis. Currently, I am using the FireFox Webdriver to ...

Using mathematical operations in Sass mixins with variable arguments

When working with CSS sizing, I prefer using rem units with pixel fallbacks and am currently creating mixins to streamline the process. For setting font sizes, it's a simple task: @mixin font-size($size) { font-size: $size + px; font-size: ($size ...

The Bulma dropdown menu fails to display its items

Currently, I am working with Bulma as my CSS framework. While trying to implement the hamburger menu, I encountered some difficulties. The documentation did not provide clear instructions on how the functionality should work. Despite observing the menu tra ...

Changing Background Color on Div Click

After spending a considerable amount of time on this, I find myself getting confused and stuck. It seems like I might be overlooking something crucial. Essentially, my code is designed to have the default div background (gamebg), and upon clicking one of t ...

Encountering an error when using Jest and the envalid library to test a React application: process.exit invoked with code "1"

While testing my React/Typescript application with Jest, I encountered an error. I am utilizing the envalid library to manage my environment variables with types and autocompletion: const ENV = cleanEnv(process.env, { | ^ 6 | R ...

Guide to incorporating vertical scrolling for a grid of items in Material UI

Is there a way to implement vertical scrolling in a grid container so that when the height of components exceeds a certain maximum, they can be scrolled through vertically? ...

"Vertical Line Encoding: A Strategy for Improved Data

Can someone help me with a coding issue I'm facing on my website? I am trying to create three vertical lines to separate images in columns, but every time I exit the editor and preview the site, the position of the lines changes. I'm new to HTML ...

What is the best way to determine if any of the objects in an array contain a "completed" property with a value of false using JavaScript and React?

Is there a way to determine if at least one item in an array of objects has a completed property with a value of false using JavaScript and React? Here is an example array of objects: const items = [ { id: "32", jobs: [ ...

Styling may vary between the CSS used in the development environment and the one

After launching my web page on a server yesterday, I noticed some differences compared to the development environment. There are a few elements with altered colors, but my main concern is the appearance of the jQuery autocomplete search widget. Instead o ...

Issue with Scatter Plot Updating Incorrectly for Multiple Data Points in Same Position

I am currently working with two teams, team1 and team2, each containing plot data in a specific structure. For reference, you can find the code structure in the link provided below. Check out my code here: https://codesandbox.io/p/sandbox/react-counter-fu ...

What is the best practice for updating state immutably in React using Redux and Redux Toolkit?

As I delve into learning Redux, I've come across a method called addPosts which allows me to add posts to my list. Here's how I'm implementing it: import { createSlice } from "@reduxjs/toolkit"; const initialState = [{ number: 1 } ...