Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

174
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda