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

251
Views
How to use logic classes with styled components

I want to use this logic to applying the corresponding class to an element:

<ul onClick={handleClick} className={click ? 'dropdown-menu clicked' : 'dropdown-menu'}>

But I am using styled components, I don't understand how I can use logic to totally change the component. Any ideas? I am using Next.js

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can pass a function ("interpolations") to a styled component's template literal to adapt it based on its props.

Read this section, Adapting based on props, in Styled Component documentation. In your case, because you didn't provide the details of the code, I can only give you an example:

const DropdownMenu = styled.div`
  display: ${props => props.clicked ? "none" : "block"};
`;
about 4 years ago · Juan Pablo Isaza Report
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!