Disabling the hover effect of a material-ui button within a styled component

I tried adding the css hover property to disable the button's hover effect, but it doesn't seem to be working for my situation. How can I go about resolving this issue?

import Button from 'material-ui/Button'
import styled from 'styled-components'

const StyledButton = styled(Button)`
  &:hover {
    background: none;
  }
`
export const SubmitButton = ({ onClick }) => {
  return (
    <StyledButton
      variant="raised"
      onClick={onClick}>
      login
    </StyledButton>
  )
}

Answer №1

To tackle this issue, simply incorporate an inline style.

const Button = ({ handleOnClick }) => {
  return (
    <StyledButton
      variant="raised"
      onClick={handleOnClick}
      style={{ backgroundColor: 'transparent' }} >
      login
    </StyledButton>
  )
}

Answer №2

Consider making it blend in with the background color:

layout = {
    backgroundColor: "#FFF"
    "&:hover": {
        //ensure this matches the backgroundColor set above
        backgroundColor: "#FFF"
    }
}

Answer №3

Here is a potential fix for version 5 if anyone finds it useful

         <CustomButton
            disabled
            disableTouchRipple
            size="smallest"
            sx={{
              marginLeft: 1,
              "&.MuiBuoyantElement-root:hover": {
                background: "clear"
              }
            }}
          >

          </CustomButton>

Answer №4

To remove the background of the button completely, you may want to consider setting it as none

button: {    
    '&:hover': {
        background: 'none',
    },
}

Answer №5

To update the style, you can utilize a styled component like this:

const CustomStyledButton = styled(Button)`
    &:hover {
      background-color: transparent;
     }
`;

Answer №6

Everything seems to be in order

const CustomButton = styled(Button)`
  &&.MuiButton-root {
    &:hover {
      background: none;
    }
  }
`

Answer №7

To remove the hover effect on a material-ui button, you can include the following details within the component. I recently implemented this for a Switch button.

disableRipple

style={{ backgroundColor: "transparent" }}

import React from "react";
import FormControlLabel from "@material-ui/core/FormControlLabel";
import Switch from "@material-ui/core/Switch";
import { withStyles } from "@material-ui/core/styles";

const styles = {
  
};

class SwitchLabels extends React.Component {
  state = {
    checked: true
  };

  handleChange = (event) => {
    this.setState({ checked: event.target.checked });
  };

  render() {
    return (
      <FormControlLabel
        control={
          <Switch
            classes={this.props.classes}
            checked={this.state.checked}
            onChange={this.handleChange}
            disableElevation
            disableRipple
            style={{ backgroundColor: "transparent" }}
            value="checked"
            color="primary"
          />
        }
        labelPlacement="start"
        label={this.state.checked ? "On" : 'Off'}
      />
    );
  }
}

export default withStyles(styles)(SwitchLabels);

Answer №8

By utilizing the original Button component together with a className, you could have easily included disableRipple to the button as shown below: <Button disableRipple>

Answer №9

Join our team

 <Button 
    sx={{
      color:'#000000', 
      background:'rgba(0, 0, 0, 0.065)', 
      width:'84px', 
      height:'51px', 
      boxShadow: '0px 0px 4px 0px #00000040',
      fontSize:'20px',
      '&:hover': {
           background:'rgba(0, 0, 0, 0.065)'
      },
    }} 
    variant="contained">
    Earn +50$
   </Button>

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

Steps to apply styles to an iframe element directly from its inner HTML code

Looking for help with this line of code: <iframe src="http://www.google.com" name="google" style="Z-INDEX: 0; MARGIN-TOP: -1px; WIDTH: 100%; HEIGHT: 1070px"> <html> <head></head> <body> < ...

Using shadow effects on the <Grid> component with Material UI

Is there a way to implement the box-shadow property on a <Grid> component in Material UI? I've gone through the official documentation regarding Shadows - Material UI, but I'm struggling to grasp how it can be applied to a <Grid>. De ...

Leveraging the power of dual CSS classes for a single element

Can you help me troubleshoot this? I have a .social div, and I want zero padding on the top for the first one, and no bottom border for the second one. I tried creating classes for the first and last scenarios, but it seems like something is off: .socia ...

The event listener for React server-side rendering is not connected to

When setting up routing on the client side, I defined the routes in index.js as follows: ReactDOM.render( <Router history={browserHistory}> <Route path="/" component={App}/> <Route path="/login" component={Login}/> ...

The React page loads before verifying the clients' permissions

In my application, I am using a Javascript query to fetch the data of the current user. This data is then used to verify the user's access permissions for different pages in my React app with the help of Apollo Client and GraphQL. Unfortunately, ther ...

"Can someone point me to the location of the onScroll event within Material

I have been unable to locate any information in the Material UI documentation that addresses how to trigger a function on scroll using the onScroll event. All of my components follow either a functional and stateless approach or they are container componen ...

Exploring the art of customizing React components with Material UI: Diving into the world

I'm currently diving into Material UI while working on a project in React. I find myself a bit perplexed about the most effective approach to styling and customizing components. Here are some options I've come across: A: Utilizing a custom them ...

Align the items in the Material UI grid centrally within the grandparent grid container

Here is a Grid component that I am working with: <Grid container height="100vh" direction="column"> <Grid item alignSelf="flex-end"> <Button variant="text">List Your Property</Button> ...

Troubleshooting: Issues with Cypress typing input text on Material-UI and Formik in a React application

I have been experimenting with the login submit function using cypress. The login form I am testing is created with material-ui and formik. Unfortunately, I am unable to access the 'data-testid' props on Input when running the test. test code ...

Ways to bring GIFs into NextJS

I am currently working on my portfolio website using Nextjs and I would like to incorporate gifs into the site. However, I have been struggling to figure out how to do so. Below is the code that I have been working with: https://i.stack.imgur.com/zjoiD.pn ...

How to set Monday as the first day of the week in MUI DatePicker

I am currently using the MUI v6 DatePicker component (https://mui.com/x/react-date-pickers/date-picker/). However, I have noticed that the weeks in the calendar are starting with Sunday instead of Monday. I am in need of assistance to change this behavior ...

Retrieve the information from the API and populate the tables with the data

I'm currently working on fetching API data and displaying it in tables, using mock data for now. Successfully implemented actions and reducers. Managed to call the API but encountered an issue with network calls where I see a blocked response content ...

Looking for CSS templates for improving your business web apps?

Many CSS templates out there are fixed-width, typically around 900 pixels wide... Right now, I'm in the process of creating an intranet Rails application and I'm seeking a good resource for CSS templates designed specifically for business applic ...

Implementing yadcf and a fixed column filter in a Bootstrap datatable

I am currently utilizing Bootstrap DataTable in conjunction with the Yadcf filter plugin. The filter is functioning correctly for a regular table, however, when I have a fixed column with a Select2 dropdown, it does not render properly. The dropdown is hid ...

Achieve full height in Grid component of material UI by eliminating margins

In this codesandbox example, I have successfully set the grid container height to full using 100vh. However, there is an issue with a margin of 8px being added by the user agent to the body element, and I'm struggling to find a solution to remove it. ...

Configuring React on the client-side along with Express.js on the backend using Webpack 4

I have successfully configured React and webpack. Below is my webpack.config.js file: const HtmlWebPackPlugin = require('html-webpack-plugin'); const path = require('path'); module.exports = { entry: { index: './client/inde ...

What is the process for creating a Sass mixin that declares a selector at the base level, rather than nested within another

Apologies for the unconventional terminology in the query, but I am struggling to find better words to describe it. Hopefully, this example will clarify my intention: scss-syntax .my-smug-selector { @include my-smug-mixin(30px); } desired css-output ...

What would be the best method in REACT QUERY for reusing global state?

When working with redux/context API, data is typically fetched and stored in the global state once, allowing it to be accessed throughout the app. For example, a USER authentication state may hold details like user ID and token. I am curious to learn abo ...

Is it possible to have the front-facing photo in expo-camera stay mirrored?

Currently, I am utilizing the expo-camera library to capture a selfie image. Despite the preview being mirrored, the final saved image reverts to its normal orientation. Is there any way to avoid this behavior so that the image remains mirrored? Alternativ ...

Preventing the Rendering of a Form Field in NextJS While Still Including it in the Submit Action

Currently, I am in the process of updating a card record that contains fields such as cardText, source, and ownedBy. The ownedBy field is an array, not editable by the user, but crucial for preserving its value during the Patch operation. To hide the owne ...