Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

112
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!