Morphing Input
uselayouts/morphing-inputFreeComponent
An input field that morphs between different states.
Live preview
live · rendered by the registry
Rendered by uselayouts on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://uselayouts.com/r/morphing-input.jsonSource
1"use client";23import { useState } from "react";4import { motion, AnimatePresence } from "motion/react";5import { Input } from "../../../components/ui/input";6import { HugeiconsIcon } from "@hugeicons/react";7import {8 ArrowRight02Icon,9 UnfoldMoreIcon,10 Album02Icon,11 SparklesIcon,12} from "@hugeicons/core-free-icons";1314interface PlaceholderConfig {15 id: number;16 placeholder: string;17 icon: any;18}1920// Change Here21const placeholderOptions: PlaceholderConfig[] = [22 { id: 1, placeholder: "Search anything...", icon: SparklesIcon },23 { id: 2, placeholder: "Generate Image", icon: Album02Icon },24];2526const AnimatedPlaceholder = ({ text }: { text: string }) => {27 const letters = text.split("");2829 return (30 <motion.span className="inline-flex overflow-hidden">31 {letters.map((letter, index) => (32 <motion.span33 key={`${text}-${index}`}34 initial={{35 opacity: 0,36 rotateX: "80deg",37 y: 8,38 filter: "blur(3px)",39 }}40 exit={{41 opacity: 0,42 rotateX: "-80deg",43 filter: "blur(3px)",44 y: -8,45 }}46 animate={{47 opacity: 1,48 rotateX: "0deg",49 y: 0,50 filter: "blur(0px)",51 }}52 transition={{53 delay: 0.015 * index,5455 type: "spring",56 damping: 16,57 stiffness: 240,58 mass: 1.2,59 }}60 style={{61 willChange: "transform",62 }}63 className="inline-block"64 >65 {letter === " " ? "\u00A0" : letter}66 </motion.span>67 ))}68 </motion.span>69 );70};7172const InputSwitch = () => {73 const [activeIndex, setActiveIndex] = useState(0);74 const [inputValue, setInputValue] = useState("");75 const currentConfig = placeholderOptions[activeIndex];7677 const handleIconClick = () => {78 setActiveIndex((prev) => (prev + 1) % placeholderOptions.length);79 };8081 const IconComponent = currentConfig.icon;8283 return (84 <div className="bg-muted w-full max-w-sm py-1 flex justify-center items-center rounded-full px-1">85 <motion.button86 className="bg-background p-2.5 px-2.5 rounded-full flex items-center justify-center gap-1.5 transition-colors overflow-hidden cursor-default shadow-sm"87 onClick={handleIconClick}88 whileTap={{ scale: 0.9 }}89 >90 <AnimatePresence mode="popLayout" initial={false}>91 <motion.div92// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from uselayouts
All 26 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| 3D Book3d-book | uselayouts | Components | Free | 3 deps | |
| Animated Collectionanimated-collection | uselayouts | Components | Free | 5 deps | |
| Bento Cardbento-card | uselayouts | Components | Free | 5 deps | |
| Bottom Menubottom-menu | uselayouts | Components | Free | 6 deps | |
| Bucketbucket | uselayouts | Components | Free | 5 deps · 2 files | |
| Day Pickerday-picker | uselayouts | Components | Free | 5 deps | |
| Delete Buttondelete-button | uselayouts | Components | Free | 5 deps | |
| Discover Buttondiscover-button | uselayouts | Components | Free | 5 deps |
