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

121
Visualizações
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 à 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