{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "inline-edit", "title": "Inline Edit", "description": "An input that switches between read and edit modes.", "dependencies": [ "motion", "@hugeicons/core-free-icons", "@hugeicons/react", "clsx", "tailwind-merge" ], "registryDependencies": [ "input" ], "files": [ { "path": "registry/default/example/inline-edit.tsx", "content": "\"use client\";\r\n\r\nimport { AnimatePresence, motion } from \"motion/react\";\r\nimport { useRef, useState } from \"react\";\r\nimport { Edit01Icon, Tick02Icon } from \"@hugeicons/core-free-icons\";\r\nimport { HugeiconsIcon } from \"@hugeicons/react\";\r\nimport { Input } from \"@/components/ui/input\";\r\nimport { cn } from \"@/lib/cn\";\r\n\r\nfunction SaveInput() {\r\n const [isEditing, setIsEditing] = useState(false);\r\n const [value, setValue] = useState(\"this.urvish\");\r\n\r\n const inputRef = useRef(null);\r\n\r\n return (\r\n
\r\n \r\n setValue(e.target.value)}\r\n readOnly={!isEditing}\r\n className={cn(\r\n \"h-12 border-0 shadow-none focus-visible:ring-0 bg-transparent p-0 text-base w-full min-w-32 pl-4 pr-12\",\r\n isEditing ? \"text-foreground\" : \"text-muted-foreground\"\r\n )}\r\n placeholder=\"username\"\r\n />\r\n \r\n {!isEditing ? (\r\n {\r\n setIsEditing(true);\r\n\r\n if (inputRef.current) inputRef.current.select();\r\n }}\r\n className=\"absolute right-1 flex items-center justify-center h-10 w-10 rounded-full bg-card/80 border border-[0.2px] hover:bg-card cursor-pointer text-muted-foreground\"\r\n >\r\n \r\n \r\n ) : (\r\n setIsEditing(false)}\r\n className=\"absolute z-20 right-1 flex items-center justify-center h-10 w-10 rounded-full border-[0.2px] bg-primary hover:bg-primary/90 cursor-pointer text-primary-foreground\"\r\n >\r\n \r\n \r\n )}\r\n \r\n \r\n
\r\n );\r\n}\r\n\r\nexport default SaveInput;\r\n", "type": "registry:component" } ], "type": "registry:component" }