Vibary.ai
← Vibe Coding

Tag Input Add

Committed text lands as a chip and the caret slides along to the space it took.

formsfriendlyenergeticinteraction · finite · intermediate · ~0.3s
Interactive · click to play
Variant

The animated component in this preview is rendered from the canonical file shown here. The surrounding demo shell only provides context and is not part of the copied code.

301 lines · react + motion only
import { useId, useRef, useState, type KeyboardEvent } from "react";
import { AnimatePresence, motion, useReducedMotion } from "motion/react";

/**
 * Vibary · Tag Input Add
 *
 * Committed text leaves the caret and lands as a chip, and the caret
 * slides along to the space the chip just took. Backspace on an empty

About this pattern

The commit is the moment worth animating: text that was in the caret a frame ago is now an object with edges, and the field it was typed into moves over to make room. Chips and caret share one critically damped reflow spring, so the row resettles as a single body — and both move with position-only layout, because a chip is a box full of text and interpolating its box would smear the glyphs inside it. Removal is faster than addition, out-of-flow immediately, so the gap closes while the chip is still fading. Backspace on an empty field puts the last chip back in the caret rather than deleting it.

Document labelsRecipient fieldSkill or interest pickerFilter builder

Where it shows up

Screens we drew to show where this motion usually sits. Illustrations, not captures of any product.

  • Add a supplierTwo fields now, the rest later
    Legal name
    Ridgeline Supply Co.
    Country
    Sweden
    VAT number
    SE556031820101
    Save supplier
    Form

    Text committing into an object the caret then moves past.

Related patterns