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

139
Views
CSS3 Animated Search Box in react not working

I am trying to create the following item for my react project http://demo.icanbecreative.com/css3-animated-search-box/ using this reference tutorial https://icanbecreative.com/article/css3-animated-search-box/. but I am having a problem trying to implement the following function

function searchToggle(obj, evt){
    var container = $(obj).closest('.search-wrapper');
        if(!container.hasClass('active')){
            container.addClass('active');
            evt.preventDefault();
        }
        else if(container.hasClass('active') && $(obj).closest('.input-holder').length == 0){
            container.removeClass('active');
            // clear input
            container.find('.search-input').val('');
        }
}

Because it uses JQuery, so I want to convert this function to be able to execute it inside my code. Try to hide the element and show it dynamically every time you press the button as follows

const [showInput, setShowInput] = useState(false);

<div className="search-wrapper">
     <div className="input-holder">
          <button className="search-icon"  onClick={()=>setShowInput((p) => !p)}><span></span></button>
               {showInput &&   <input type="text" className="search-input" placeholder="Type to search" /> }
           </div>
      <span className="close" onClick={displaySearchToggle}></span>
</div>

But it is not working.but it is not working, the button appears correctly but when pressed it does not show the input

about 4 years ago · Juan Pablo Isaza
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!