title: toggle between multiple button style on click of button in react
body: <p>I want to change the style of buttons when clicked on them.</p>
  <p>Below are my files.</p>
  <p>App.js:</p>
  <pre><code>class Test extends Component {
    constructor(){
           super();
           this.state = {
                black: true
           }
      }
      changeColor(){
          this.setState({black: !this.state.black})
      }
      render(){
          let btn_class1 = this.state.black ? &quot;blackButton&quot; : &quot;whiteButton&quot;;
          let btn_class2 = this.state.black ? &quot;whiteButton&quot; : &quot;blackButton&quot;;
          let btn_class3 = this.state.black ? &quot;whiteButton&quot; : &quot;blackButton&quot;;
  
          return (
               &lt;div&gt;
                   &lt;button className={btn_class1}
                           onClick={this.changeColor.bind(this)}&gt;
                             Button1
                    &lt;/button&gt;
                    &lt;button className={btn_class2}
                           onClick={this.changeColor.bind(this)}&gt;
                             Button2
                    &lt;/button&gt;
                    &lt;button className={btn_class3}
                           onClick={this.changeColor.bind(this)}&gt;
                             Button3
                    &lt;/button&gt;
               &lt;/div&gt;
          )
      }
  }
  export default App;
  </code></pre>
  <p>color.css:</p>
  <pre><code>button{
    width: 80px;
    height: 40px;
    margin: 15px;
  }
  .blackButton{
    background-color: black;
    color: white;
  }
  
  .whiteButton{
    background-color: white;
    color: black;
  }
  </code></pre>
  <p>At the start I want my button1 to have a black background, and button2 and button3 should have a white background.</p>
  <p>When I click on button2, then it should have black background, and button1 and button3 should have white background.</p>
  <p>Similarly with button3: when clicked upon, it should have a black background, and button1 and button2 should change to a white background.</p>