Input
Button Input
NewAn e-mail field with a subscribe button that checks the address, spins while sending and fades into a thank-you line.
npx motionsnack add button-inputCustomize
<ButtonInput />Props
28 properties
| Property | Type | Default | Description |
|---|---|---|---|
| value | string | - | Controlled value. Leave undefined to let the component manage it. |
| defaultValue | string | '' | Value on first render when uncontrolled. |
| onChange | (value: string) => void | - | Called with the new text on every change. |
| onSubmit | (email: string) => void | Promise<unknown> | - | Called with a valid e-mail. A returned promise keeps the spinner until it settles; a rejection shows the error text. Without it the submit is simulated. |
| error | string | '' | Error message from the caller (e.g. a server error). Wins over the built-in messages. |
| buttonColor | string | - | Deprecated: section styling. The button is the inverse fill. |
| buttonTextColor | string | - | Deprecated: section styling. The button is the inverse fill. |
| buttonRadius | number | - | Deprecated: the button follows the field. |
| name | string | - | Name submitted with a form. |
| id | string | generated | Id of the input. |
| className | string | '' | Extra classes on the wrapper. |
| layout | 'inside' | 'attached' | 'separate' | 'inside' | Button inside the field, joined to it, or next to it (stacks on narrow widths). |
| label | string | '' | Label above the field. Empty hides it; the placeholder then names the field for screen readers. |
| placeholder | string | 'you@studio.com' | Hint inside the empty field. |
| buttonLabel | string | 'Subscribe' | Text of the button. |
| helperText | string | 'One e-mail a month. No spam.' | Small text under the field. Empty hides it. |
| successText | string | 'Thanks! Check your inbox to confirm.' | Line shown after a successful submit. |
| invalidText | string | 'Enter a valid e-mail address.' | Message when the address is not a valid e-mail. |
| errorText | string | 'Something went wrong. Please try again.' | Message when onSubmit rejects. |
| resetLabel | string | 'Use another address' | Link that brings the field back after a successful submit. |
| allowReset | boolean | true | Offer the reset link after a successful submit. |
| icon | 'mail' | 'none' | 'mail' | Icon at the start of the field. |
| disabled | boolean | false | Disables the field and the button. |
| required | boolean | false | Marks the field as required. |
| errorColor | string | '' | Error colour for both themes. Empty uses the per-theme pair. |
| height | number | 48 | Height of the field. |
| radius | number | 12 | Corner radius of the field for the attached and separate layouts. The inside layout is always a pill. |
| simulateMs | number | 900 | How long the submit takes when there is no onSubmit. |
About Button Input
Button Input is the newsletter field every site needs: an e-mail address and one button. The button sits inside the field, joined to its edge or next to it, and the separate layout stacks the two full width on narrow screens. Submitting checks the address first; a wrong one turns the field's border red with a short message. While onSubmit runs the label cross-fades into a spinner without changing the button's width, and once it settles the whole row fades into a line with a drawn check mark and a link to use another address. A rejected promise brings the field back with an error message. The button takes the site's buttonColor, buttonTextColor and buttonRadius, and every text is a prop.
What's included
- Button inside, attached or separate
- E-mail check with an error message
- Spinner that keeps the button's width
- Cross-fade into a success line with a drawn check
- Async onSubmit with an error state
- Site button colours and radius
- Light and dark look
- Type
- Animated React input component
- Library
- Components · Input
- Stack
- Next.js, React, Tailwind CSS
- Added
- 2026-11-23
- Install
npx motionsnack add button-input