Join the Discord!
Buttons

Input Button

Animated button that transforms into an input field with smooth layout transitions. Perfect for React applications requiring dynamic form interactions with Next.js integration and TypeScript support.

Loading component...

Installation

npx shadcn@latest add https://www.shadcn.io/registry/input-button.json
npx shadcn@latest add https://www.shadcn.io/registry/input-button.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/input-button.json
bunx shadcn@latest add https://www.shadcn.io/registry/input-button.json

Features

  • Smooth layout transitions using Motion's layoutId for seamless button-to-input morphing
  • Compound component pattern with provider, action, submit, and input components
  • Loading state handling with built-in pending states and success feedback
  • Accessible form integration supporting proper form submission and validation
  • TypeScript support with complete interface definitions for all sub-components
  • shadcn/ui integration using design tokens and consistent styling patterns

Examples

Loading States

Loading component...

Demonstrates form submission with loading indicators and success states.

Use Cases

This free open source React component works well for:

  • Newsletter signups - Email collection with smooth interaction flow built with Next.js
  • Search interfaces - Expandable search boxes using TypeScript and Tailwind CSS
  • Quick actions - Compact forms that expand on demand for better UX
  • CTA buttons - Call-to-action elements that transform into input forms

API Reference

InputButtonProvider

PropTypeDefaultDescription
showInputbooleanfalseControls input visibility state
setShowInputfunction-State setter for input visibility
transitionTransition{ type: 'spring', stiffness: 300, damping: 20 }Motion transition configuration
idstringuseId()Unique identifier for layout animations

InputButtonAction

PropTypeDefaultDescription
onClickfunction-Click handler for button action
childrenReactNoderequiredButton text content

InputButtonSubmit

PropTypeDefaultDescription
iconReact.ElementTypeArrowRightIcon component for collapsed state
childrenReactNode-Submit button text content
disabledbooleanfalseDisables the submit button

InputButtonInput

PropTypeDefaultDescription
typestring"text"HTML input type attribute
placeholderstring-Input placeholder text
valuestring-Controlled input value
onChangefunction-Input change handler

Implementation Notes

  • Uses compound component pattern with context for state management
  • Layout animations powered by Motion's layoutId system
  • Automatic focus management when input appears
  • Supports both controlled and uncontrolled usage patterns
  • Compatible with shadcn/ui form components and validation
  • Optimized for keyboard navigation and screen readers