A Search Bar
This is another DailyUI where I can’t resist coding the thing. The idea was to explore ways to animate a search bar. In this particular scenario, a circular button unrolls to create a search field. The idea was so simple and fun that I had to code it. You’ll see its very simple! Check out the demo.
The main mechanic makes use of the dasharray and dashoffset properties for SVG strokes. In this case, the whole SVG path starts from the end of the text field and comes around the circle. They are not two separate paths! Therefore it makes it easier to animate it using only the two dash properties. The circle is 36px in diameter, which makes a circumference of roughly π36 = 113.097. This is our dasharray value. The length of the text field is exactly 200px. This is our dashoffset value. Something I had to figure out was that the dashoffset is calculated from the bounding box. not from the length of the path. Therefore, the dashoffset needs to be negative, so that the first dasharray starts at -199 (I had to give it a little room to accommodate the imprecision of my circumference) from the starting point.
In the end, I still think my code is a little intense for a search box, but the goal was to create a neat little animation. Use it, implement it, modify it, cite me if you want, and keep coding!