shadcn.io is not affiliated with official shadcn/ui
Centered Email Capture Form Hero Block for React
A compact centered newsletter hero with the email field in a full-width band between two hairlines: a Shine Button subscribes, then a confirmation replaces the form, over a row of subscriber proof.
Installation
Overview
A compact centered hero built around one email field. An announcement pill links to the latest issue, then a headline and a sentence lead into a full-width band, tinted and ruled top and bottom with + marks on its ends, that holds the field and a Shine Button labelled Subscribe, the one primary action. The block checks the address before it sends: an empty or malformed one gets a message under the field, and a good one shows a spinner in the button, then a confirmation in the form's place. Under the band, five subscriber avatars, a subscriber count and a free-forever line. It's built from Guides, Field, Input, Shine Button, Avatar, Announcement and Status, with Lucide icons, Tailwind CSS and CSS transitions. The fictional product is Workbench Weekly, a design engineering newsletter. For newsletters, creators, indie makers and any product whose main goal is a growing email list.
FAQ
How do I connect the form to my email service?
The submit handler checks the address, then sets the block to sending and, after a timer that stands in for the request, to done. Replace the timer with the call to your service's API, or your own endpoint, and set done when it answers. If it fails, set the phase back to idle and put the service's message in the error, and it shows under the field like a validation message.
How is the address checked?
The form has noValidate, so the browser's own bubbles stay out and the block checks the address itself, with a pattern that wants something, an @ and a domain with a dot. An empty field says Enter your email address, and a malformed one asks for a valid address with an example. The message clears as soon as you type, and the field is marked invalid until then.
How does the form work with a screen reader and the keyboard?
The field has a label, Email address, that's read but not shown, and its error is tied to it, so the field reads as invalid with the message. A failed submit moves focus to the field. While sending, the button keeps its name, shows a spinner and can't be pressed twice, and a polite live region says Subscribing. When it's done, focus moves to the confirmation, which is read out, so focus never falls back to the top of the page. The avatars are decoration and hidden; the count beside them is real text.
How do I show my real subscriber count?
Fetch the count from your email service where the page is built, cache it, and render it in place of 12,437, with your locale's number format. The five avatars are initials of recent subscribers: swap in their photos with AvatarImage, keeping AvatarFallback for anyone without one.
How does the form fit on a phone?
Below the sm breakpoint the Subscribe button goes under the field, at full width, and the proof row stacks: the avatars and the count, then the free-forever line. The headline drops its forced line break and wraps balanced at text-4xl. An error pushes only the content below it down, never the button sideways.
Related
- Pro
Centered Inline Email Signup Hero
Signup and waitlistA short centered waitlist hero with an email field and a Shine Button on one row inside a framed box, a confirmation in place, an avatar row and two trust points.
- Pro
Centered Email Signup Hero
Signup and waitlistA compact centred hero built around one email field and a Shine Button, between solid rails, with a proof band below: the people on the list, when invites go out and what it connects to.
- Pro
Waitlist Signup Hero
Signup and waitlistA compact waitlist hero: the copy beside a card-in-card email form that turns into a confirmation in place, with a closing band of three features coming at launch.
- Pro
Centered Newsletter Archive Hero
Signup and waitlistA centered newsletter hero with an email signup that confirms in place, over the four latest issues as links in one hairline grid between the rails.
- Pro
Split Signup Form Hero
Signup and waitlistA split hero with a sign-up form on the page: copy and ticks at the start, and a card in card form at the end with a work email, a password and a Shine Button that shows a spinner, then a confirmation.
- Pro
Reverse Split News List Hero
Updates and timelinesA reverse split hero on drafting lines for a team docs workspace: a greyscale product illustration beside an announcement pill, the headline, a ruled list of the latest updates as links, a Shine Button and a second action.