Subscription Form
ProNewEmail capture as a card, an inline row, a full-width bar or a picture split, with loading, success and error states built in.
Installation
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
Props
| Prop | Type | Default |
|---|---|---|
| onSubscribe* | (subscriber: Subscriber) => void | Promise<unknown>Called with the address once it passes validation. Return a promise to show the loading state; reject with an `Error` to show its message under the field. | — |
| layout | "inline" | "card" | "bar" | "split"`inline` is a field and button in a row, `card` a centered card, `bar` a full-width strip, `split` a picture beside the form. | "card" |
| title | string | "Subscribe to our newsletter" |
| description | string | — |
| askName | booleanAsk for a first name above the email. | false |
| placeholder | string | "Enter your email here..." |
| buttonLabel | string | "Subscribe" |
| note | stringSmall print under the form, such as “No spam. Unsubscribe anytime.” | — |
| consent | React.ReactNodeAdds a required checkbox with this label, for consent to your terms. | — |
| image | stringPicture for the `split` layout. | — |
| imageAlt | string | "" |
| imageSide | "left" | "right"Side of the picture on wide containers. It always stacks on top on phones. | "left" |
| accent | stringAny CSS color, for the button and focus ring. | "#1672f3" |
| successTitle | string | "You're on the list" |
| successMessage | string | "Check your inbox to confirm your address." |
| errorMessage | stringShown when `onSubscribe` rejects without a message of its own. | "Something went wrong. Please try again." |
| onDismiss | () => voidWith `layout="bar"`, shows a close button and calls this when it is pressed. | — |
| disabled | boolean | false |
| className | string | — |
Accessibility
- Every field has a real label, visible in the card and split layouts and for screen readers only in the compact ones.
- Validation runs on submit: the message is tied to the field with aria-describedby, announced as an alert, and focus returns to the field.
- The button stays focusable while the request runs; loading and success are announced through a live region.
- On success the confirmation replaces the form and takes focus, so keyboard users are never dropped at the top of the page.
- The check draws and the error shakes only when motion is allowed.