{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "input-button", "type": "registry:ui", "title": "Input Button", "description": "A button that shows an input when clicked.", "dependencies": [ "motion" ], "files": [ { "path": "registry/buttons/input/index.tsx", "content": "'use client';\n\nimport * as React from 'react';\nimport {\n AnimatePresence,\n HTMLMotionProps,\n motion,\n Transition,\n} from 'motion/react';\nimport { ArrowRight } from 'lucide-react';\nimport { cn } from '@/lib/utils';\n\ntype InputButtonContextType = {\n showInput: boolean;\n setShowInput: React.Dispatch>;\n transition: Transition;\n id: string;\n};\nconst InputButtonContext = React.createContext<\n InputButtonContextType | undefined\n>(undefined);\n\nconst useInputButton = (): InputButtonContextType => {\n const context = React.useContext(InputButtonContext);\n if (!context) {\n throw new Error('useInputButton must be used within a InputButton');\n }\n return context;\n};\n\ntype InputButtonProviderProps = React.ComponentProps<'div'> &\n Partial;\n\nfunction InputButtonProvider({\n className,\n transition = { type: 'spring', stiffness: 300, damping: 20 },\n showInput,\n setShowInput,\n id,\n ...props\n}: InputButtonProviderProps) {\n const localId = React.useId();\n const [localShowInput, setLocalShowInput] = React.useState(false);\n\n return (\n \n \n \n );\n}\n\ntype InputButtonProps = HTMLMotionProps<'div'>;\n\nfunction InputButton({ className, ...props }: InputButtonProps) {\n return (\n \n );\n}\n\ntype InputButtonActionProps = HTMLMotionProps<'button'>;\n\nfunction InputButtonAction({ className, ...props }: InputButtonActionProps) {\n const { transition, setShowInput, id } = useInputButton();\n\n return (\n setShowInput((prev) => !prev)}\n {...props}\n />\n );\n}\n\ntype InputButtonSubmitProps = HTMLMotionProps<'button'> & {\n icon?: React.ElementType;\n};\n\nfunction InputButtonSubmit({\n className,\n children,\n icon: Icon = ArrowRight,\n ...props\n}: InputButtonSubmitProps) {\n const { transition, showInput, setShowInput, id } = useInputButton();\n\n return (\n setShowInput((prev) => !prev)}\n {...props}\n >\n {showInput ? (\n \n {children}\n \n ) : (\n \n \n \n )}\n \n );\n}\n\ntype InputButtonInputProps = React.ComponentProps<'input'>;\n\nfunction InputButtonInput({ className, ...props }: InputButtonInputProps) {\n const { transition, showInput, id } = useInputButton();\n\n return (\n \n {showInput && (\n
\n \n \n \n
\n )}\n
\n );\n}\n\nexport {\n InputButton,\n InputButtonProvider,\n InputButtonAction,\n InputButtonSubmit,\n InputButtonInput,\n useInputButton,\n type InputButtonProps,\n type InputButtonProviderProps,\n type InputButtonActionProps,\n type InputButtonSubmitProps,\n type InputButtonInputProps,\n};\n", "type": "registry:ui", "target": "components/animate-ui/buttons/input.tsx" } ] }