2

I have recently started doing React programming and I am currently working on sidebar navigation. I am using React Semantic UI for my website and I have buttons for my navigation. However there is a problem I can't find a solution for, I am trying to disable the hover effect on buttons and I've tried multiple things (assigning a class to Button Group/ div and try to access it from CSS for example) but without luck. Here's my code any suggestions will be appreciated

  import React, { Component } from "react";
    import { Button, Icon } from "semantic-ui-react";
    import "../styles/DotNav.css";

    export default class DotNav extends Component {
     state = { activeItem: "home" };

  handleContextRef = contextRef => this.setState({ contextRef });

  handleItemClick = (e, { name }) => this.setState({ activeItem: name });

  render() {
    return (
      <div style={{ position: "fixed", marginLeft: 1370, marginTop: 100 }}>
        <Button.Group vertical className="ui black Change">
          <Button basic>
            <Icon name="minus" color="white" />
          </Button>
          <Button className="btn" basic>
            <Icon name="minus" color="white" />
          </Button>
          <Button basic>
            <Icon name="minus" color="white" />
          </Button>
        </Button.Group>
      </div>
    );
  }
}
4
  • Can you post the css code you used to override the semantic's one ? I work with semantic ui for react every day so I may help Commented Sep 10, 2018 at 12:47
  • .ui.inverted.black.segment.Change:hover { background-color: #202020 !important; color: #202020 !important; } @MosèRaguzzini Commented Sep 10, 2018 at 13:05
  • Try with .ui.inverted.black.segment.Change button:hover as path as your current path will affect only Button.Group Commented Sep 10, 2018 at 13:11
  • does not work, the hover & active state are still white @MosèRaguzzini Commented Sep 10, 2018 at 13:14

1 Answer 1

1

Maybe your path to element is invalid, check my snippet:

https://codepen.io/anon/pen/QVQjMY

const {
  Button,
  Container,
  Divider,
  Header,
  Icon,
  Message,
} = semanticUIReact

class App extends React.Component {
  render() {
    return (
      <Button.Group vertical className="ui black change">
          <Button>
            <Icon name="minus" color="white" />
          </Button>
          <Button className="btn">
            <Icon name="minus" color="white" />
          </Button>
          <Button>
            <Icon name="minus" color="white" />
          </Button>
        </Button.Group>
    )
  }
}

// ----------------------------------------
// Render
// ----------------------------------------
const mountNode = document.createElement('div')
document.body.appendChild(mountNode)

ReactDOM.render(<App />, mountNode)
body {
  background-color: red;
}

.ui.black.change button:hover{
  background-color: teal!important;
}

Sign up to request clarification or add additional context in comments.

3 Comments

Love it! Thanks!
What would be the way to change the active button color. I mean when button is selected?
You're welcome, mate! Same code ... instead of ":hover", ":active".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.