Last active
September 29, 2025 12:15
-
-
Save Ciantic/893ca9e7f77116c151c681affbc6a78b to your computer and use it in GitHub Desktop.
Tailwind4, DaisyUI 5 auto-expanding search field with button appearing on the right
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <form className="inline-flex input pl-[2.5em] pr-0 w-0 has-[input:not(:placeholder-shown)]:w-[250px] focus-within:w-[250px] has-[input:not(:placeholder-shown)]:[&_.btn]:block transition-[width] duration-300 ease-in-out has-[input:placeholder-shown]:border-transparent has-[input:placeholder-shown]:shadow-none" method="GET" action="/search"> | |
| <label className="overflow-hidden flex-1"> | |
| <div className="h-[100%] w-[2.5em] absolute left-0 top-0 cursor-text"> | |
| <svg | |
| aria-hidden="true" | |
| className="h-[1em] w-[1em] absolute left-[0.2em] top-1/2 -translate-y-1/2 ml-2" | |
| xmlns="http://www.w3.org/2000/svg" | |
| viewBox="0 0 24 24" | |
| > | |
| <g | |
| stroke-linejoin="round" | |
| stroke-linecap="round" | |
| stroke-width="2.5" | |
| fill="none" | |
| stroke="currentColor" | |
| > | |
| <circle cx="11" cy="11" r="8"></circle> | |
| <path d="m21 21-4.3-4.3"></path> | |
| </g> | |
| </svg> | |
| </div> | |
| <input name="q" type="search" required aria-label="Search from site" placeholder="Search" pattern=".{3,}" title="Must be at least 3 characters long" /> | |
| </label> | |
| <button className="btn btn-sm btn-secondary mr-[0.3em] hidden"> | |
| Search | |
| </button> | |
| </form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment