Clear to dustNew
One call before you clear a field: its text lifts away left to right as fine dust in its own colour, in under half a second.
Used forPrompt fieldsSearchComposersForms
Install with the shadcn CLI
Registered the namespace? Then it’s shadcn add @hairline/clear-to-dust. Set it up
Templates
Need the whole page?
61 Next.js landing pages, each designed from scratch. Try any of them live; one is $39, all of them $159, and 6 are free.
Where it’s used
Prompt fields
Clear an image or chat prompt with its own clear button.
Search
Wipe a search query when the clear button is pressed.
Composers
Clear a message box after sending, or on Escape.
Forms
Reset a field without a jarring blank.
What it handles for you
A clear button usually blanks the field in one frame, with nothing to say what was there or that it went on purpose.
One call, your state
clearToDust(field) only draws; you clear the value yourself, on the same line, the way you already do.
Exactly where it was
The text is drawn with the field’s own font, padding, alignment and scroll, so the dust starts where the letters were.
Textareas too
Lines are wrapped to the field’s width and follow its scroll, so a long prompt clears line by line.
Never blinks
The first frame is drawn at the call, so the text can’t vanish for a frame when your state clears.
Short on purpose
About 0.45s and a few dozen pixels, the budget for something done many times a day.
Passwords stay dots
A password field turns into dust as its dots, never its text.
Overview
Clearing a prompt is something people do many times a day, and it usually just blanks. Call clearToDust on the input or textarea right before you clear its value: it takes a snapshot of the text exactly where it sits (font, padding, scroll position, wrapped lines), so your state can clear on the very next line, and then the letters lift away from left to right as fine dust in the text’s own colour. It is short on purpose, about 0.45s and a few dozen pixels of travel: you notice it the first time and stop noticing it after that.
States
- clearing
- The text is drawn over the field and a front crosses it in the first 40% of the run; behind it each sampled point lifts 8 to 34px up and 12 to 57px right as it fades. 450ms by default.
- cleared
- The last dust fades and the layer is removed; the promise resolves. The field shows whatever your state now holds (its placeholder).
- reduced motion
- Nothing is drawn; the field simply clears.
Usage
On Escape and on send
Clear the composer with dust when someone presses Escape, and after a message is sent.
Props
- clearToDust(field, options?)
- Promise<void>
- Blows the field’s current text away. Call it right before you clear the value; it resolves when the dust has gone.
- options.duration= 450
- number
- Milliseconds for the whole clear.
Accessibility and motion
- It never changes the field’s value or focus; your state stays the one source of truth.
- The dust is drawn on one canvas in a layer over the page, removed when it ends, and follows the field if the page scrolls meanwhile.
- Text is sampled every 1.5 CSS pixels at device resolution, so thin and thick fonts both read as their own letters.
- Under reduced motion it draws nothing and resolves at once.
Requirements
React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.
Source
Registry item: /r/clear-to-dust.json


