Skip to content
Sign upGet access
MicrointeractionsErase wipeMenu

Erase wipe

Clearing the composer as wiping a board: an eraser sweeps back and the words vanish behind it.

Clear the composer and an eraser sweeps from the end of the text back to the start, the words disappearing behind it.

A small eraser enters at the end of the text and sweeps back to the start, and the words disappear behind it as it passes; at the start it lifts away and the field is empty. Long drafts take a little longer, never more than half a second. It is a function, so it works on any field you already have.

Installation

$ pnpm dlx shadcn@latest add https://chatcn.dev/r/erase-wipe.json

Usage

tsx
import { eraseWipe } from "@/components/ui/chatcn/erase-wipe"

<button onClick={() => eraseWipe({ field: inputRef.current, onCleared: () => setValue("") })}>Clear</button>

Props

PropTypeNotes
fieldHTMLElementThe input or textarea
onCleared() => voidClear the value here; runs once the eraser has passed
durationnumberDefault scales with the text, 280 to 520 ms

Accessibility

  • The eraser is decorative and hidden; focus stays in the field.

Motion

  • A clip-path wipe on the field and the eraser share one keyframe easing. Reduced motion: the field just clears.