Erase wipe
Clearing the composer as wiping a board: an eraser sweeps back and the words vanish behind it.
On this page
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
Usage
import { eraseWipe } from "@/components/ui/chatcn/erase-wipe"
<button onClick={() => eraseWipe({ field: inputRef.current, onCleared: () => setValue("") })}>Clear</button>Props
| Prop | Type | Notes |
|---|---|---|
field | HTMLElement | The input or textarea |
onCleared | () => void | Clear the value here; runs once the eraser has passed |
duration | number | Default scales with the text, 280 to 520 ms |
Accessibility
- The eraser is decorative and hidden; focus stays in the field.
Motion
- A
clip-pathwipe on the field and the eraser share one keyframe easing. Reduced motion: the field just clears.