Drain awayNew
One call for a move: the element’s edges let go first and everything spirals into its own centre, as if it went somewhere.
Used forInbox and feedsFile managerAI image historyTask boards
Install with the shadcn CLI
Registered the namespace? Then it’s shadcn add @hairline/drain-away. 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
Inbox and feeds
Archive a message, a card or a notification.
File manager
Move an image into a folder and see it go in.
AI image history
Send a generation to a collection or a project.
Task boards
Mark a card done and drain it from the board.
What it handles for you
Archiving usually looks like deleting, which makes people wonder whether they just lost something.
Says where it went
A spiral into the centre reads as moved, not destroyed, so archive and delete look different.
One call, any element
drainAway(element) works on an image, a card or a row; your state and API stay yours.
Edges first
The outside lets go first and the middle last, so the picture shrinks into itself.
Undo spins it out
undoAway plays it back from the centre, from wherever it is.
Real colours
Pictures are read pixel by pixel, so the spiral is the picture itself.
Pictures from anywhere
Without CORS the element closes behind a shrinking round mask and the grains take its own colours.
Overview
For the removal that isn’t a delete. When something is archived, moved to a folder or sent, it hasn’t been destroyed, it has gone somewhere, and sand or embers would say the wrong thing. Call drainAway on it: the edges let go first and every grain spirals in towards the middle, shrinking as it turns, until the picture is a point and then nothing. The promise resolves and you remove it from the list it left. undoAway spins it back out from the centre.
States
- draining
- The edge lets go first over the first 58% of the run; each grain is pulled to the centre as the square of its life, turning up to 3.6 radians and shrinking to a quarter. About 1s on a picture, 0.6s on a row.
- gone
- The last grain reaches the centre and fades. drainAway resolves true; the element stays hidden in place until you remove it.
- undoing
- undoAway plays it back 30% quicker: the grains spin out from the centre into place.
- reduced motion
- The element fades out and back in, in 160ms.
Usage
Archive with Undo
Drain the card away, archive it on your server, and let Undo spin it back out. This uses sonner, but any toast works.
Props
- drainAway(element, options?)
- Promise<boolean>
- Drains the element away. Resolves true once it has gone (it stays hidden in place until you remove it), or false if undoAway brought it back first.
- undoAway(element)
- Promise<boolean>
- Spins it back out and shows the element again. Resolves true once it is back.
- isAway(element)
- boolean
- True while the element is removed or being removed and not brought back.
- options.duration= 1000 (600 on rows)
- number
- Milliseconds for the whole removal.
Accessibility and motion
- The spiral is worked out per grain from where it sat, so wide rows drain into a flat point and squares into a round one.
- Pictures are drawn from their pixels in a canvas over the page while the element is hidden in place; serve pictures from other origins with CORS and crossOrigin="anonymous" for their real colours.
- Announce the move in your own status line; the element leaves the accessibility tree once hidden.
- Under reduced motion the element fades out and in instead.
Requirements
React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.
Source
Registry item: /r/drain-away.json


