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

114
Vistas
how to set a active state on a button with styled components - Reactjs

I have a few buttons in my navbar and I want to set an active class with some styles to them when they are clicked. I am using styled components for styling. I have no idea how to set an active state on a button please suggest me how to do it. Below are my codes

style

export const NavButton = styled.button`
  border: none;
  outline: none;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  /* height: 100%; */
  padding: 0.3rem 1.5rem;
  background: transparent;
  cursor: pointer;
  transition: all 0.5s;

  &:hover {
    font-weight: 700;
    background: rgba(204, 204, 204, 0.486);
    border-radius: 0.3rem;
  }
`;

jsx

 <PrimaryNav>
        <NavUl>
          <li>
            <NavButton>Civil</NavButton>
          </li>
          <li>
            <NavButton>Criminal</NavButton>
          </li>
          <li>
            <NavButton>Corporate</NavButton>
          </li>
          <li>
            <NavButton>Service</NavButton>
          </li>
          <li>
            <NavButton>Taxation</NavButton>
          </li>
          <li>
            <NavButton>Acts</NavButton>
          </li>
          <li>
            <NavButton>Notifications</NavButton>
          </li>
        </NavUl>
      </PrimaryNav>
about 4 years ago · Santiago Gelvez
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