Components

Vanish Input

An animated prompt and search input for React: the placeholder cycles through suggestions with a soft slide and blur, and when you press Enter your text dissolves into particles before the field clears. A great fit for AI chat boxes, search bars and hero prompts.

  • Cycling placeholders
  • Particle dissolve
  • Enter to submit
  • Controlled or uncontrolled
  • Canvas
  • Reduced-motion fade

What should we build?

Type something and press Enter.

Installation

$ npx shadcn@latest add https://duskui.com/r/vanish-input.json

On submit the text is painted onto a canvas with the input's own font and color, sampled into particles, and blown away; the field clears at the same instant, so there's no flicker.

Usage

prompt.tsx
"use client"

import { VanishInput } from "@/components/dusk/vanish-input/vanish-input"

export function Prompt() {
  return (
    <VanishInput
      placeholders={["Ask anything…", "Summarize my inbox…", "Plan a trip to Lisbon…"]}
      onSubmit={(value) => console.log(value)}
    />
  )
}

Examples

Restyle the field with className and the wrapper with containerClassName. interval sets how long each placeholder stays.

    Controlled

    Pass value and onValueChange to control the text, here to cap its length. After a submit, onValueChange is called with an empty string.

    0/60 characters

    API Reference

    Any other input prop (name, maxLength, autoFocus…) is passed to the input. Empty or whitespace-only values are never submitted.

    PropTypeDefaultDescription
    placeholdersstring[]["Ask anything…"]Suggestions that take turns as the placeholder.
    intervalnumber3000Milliseconds each placeholder stays.
    onSubmit(value: string) => void—Called with the trimmed text on Enter or the button.
    valuestring—Controlled value.
    defaultValuestring""Initial value when uncontrolled.
    onValueChange(value: string) => void—Called on every change, and with "" after a submit.
    labelstringfirst placeholderAccessible name of the field.
    submitLabelstring"Submit"Accessible name of the submit button.
    containerClassNamestring—Classes for the outer form.
    classNamestring—Classes for the input.

    Accessibility

    • The field has a stable accessible name (label); the cycling placeholder is decorative and hidden from screen readers.
    • It's a real form: Enter submits, and the submit button has its own label and uses aria-disabled while the field is empty.
    • Placeholders only cycle while the field is empty, visible on screen and the tab is in front.
    • With prefers-reduced-motion placeholders crossfade without sliding, and submitted text fades out instead of scattering.