Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

171
Visualizações
Is there a way to change the color/state of a button in react depending on how each state?

I am trying to change the color of the button, depending on "each state". For e.g, if the state is active, the colour of the button would be red. otherwise it would be blue. Does anyone have an idea on how to implement that on react? Additionally, i would like to have different state, instead of just two. e.g. active, inactive, activating, pending etc.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

is this what you're looking for ?

import { useState } from "react";

export default function App() {
  const [state, setState] = useState("active");

  return (
    <div className="App">
      <button style={{ color: state === "active" ? "#F00" : "#00F" }}>
        click me
      </button>
    </div>
  );
}
about 4 years ago · Juan Pablo Isaza Relatório

0

To make the bullet a dot, you can set border-radius into the style. Personally, I suggest you do this on a separate css file rather than directly in the attributes.

So you can have a style.css file

.App button {
    border-radius: 100%; // for a circle
}

And in your main js file

import { useState } from "react";
import './style.css'; // Or what ever path style.css is in

export default function App() {
  const [state, setState] = useState("active");

  return (
    <div className="App">
      <button style={{ color: state === "active" ? "#F00" : "#00F" }}>
        click me
      </button>
    </div>
  );
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda