Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Subscribe or Write Contact Block for React

A card in card with a switch between two real forms, subscribe (an email and how often) and write to us (name, email and message), that never changes size and confirms in place.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

A contact section for React with Base UI that holds two ways in behind one door. A centred header sits over a card in card: a tinted shell with + marks on its corners and a raised panel. A Segment Group at the top of the panel switches between Subscribe (an email and how often, in a Select) and Write to us (name, email and a message). Both forms are real and stay in the same grid cell, so the card never changes size; the one not showing is inert and invisible, and the email you typed follows you across. Each form checks itself on submit, shows each problem under its field, marks the control invalid and moves focus to the first one; a valid send turns the whole panel into a confirmation that says what was done. It's built from Segment Group, Select, Field, Input, Textarea, Frame, Guides, Shine Button and Button, with CSS transitions for the entrances and your theme's tokens for every colour. For newsletters, blogs and shops that want a sign-up and a "contact us" in one place.

FAQ

Where do the forms send their data?

Nowhere yet. The submit handler waits 800 milliseconds, as a stand-in for a request, then shows the confirmation. In submit, mode says which form was sent: send details.email and details.frequency to your mailing list for Subscribe, or details to your inbox for Write to us. The confirmation doesn't claim a confirmation email was sent.

Why doesn't the card change height when I switch?

The two forms sit in one grid cell, so the cell is as tall as the taller one (Write to us) and the other fades out inside it. The form that isn't showing is inert and invisible, so keyboard users and screen readers never reach it. Subscribe fills the extra room with what each issue holds.

How is the frequency select labelled?

The label above it names the select's button for screen readers. The select's trigger takes the id, and the label points to it with htmlFor.

How does each form check what's typed?

Both forms have noValidate, so the browser's bubbles stay away. On submit, problems checks the form that shows: an email with an @ and a domain for Subscribe; a name, an email and a message for Write to us. Typing in a field clears its message, and switching forms clears all of them.

What does the confirmation say, and who hears it?

For Subscribe it names the email and how often the issue goes out; for Write to us it thanks the visitor by first name and repeats the email. It's a status region that takes focus when it appears, so a screen reader reads it at once, and its button ("Use another email" or "Write another message") brings the forms back and focuses the first field.

How does it fit on a phone?

The shell sits inset from the rails so its corner marks stay inside them. The switch and the fields fill the card, the buttons go full width, and the card is shorter than a screen.

  • Pro

    The calmest contact form, for a mail client: a centred heading and three fields on the page column with inline validation, a message counter and a one-line thank-you.

  • Pro

    Support Channels Contact

    Support and feedback

    A support desk for a help desk tool: a band of four channels with their response times above a form with a subject, a normal or urgent priority and a message, which checks itself and confirms in place.

  • Pro

    A call to action between solid rails that follows the page theme, in a card in card with a two-step email capture: an email field and a Shine Button, then a six-digit code that verifies on the sixth digit and turns into a confirmation in the same space.

  • Pro

    An early-access signup for a design studio: a labelled email field with the Shine Button inside it, a validation message, a polite success line and a ghost Remind me later.

  • Pro

    A contact form that tries to answer first: five numbered answers in an accordion beside a form whose subject field opens the answers that match, then checks itself and confirms in place.

  • Pro

    A habit-app beta form with a platform segment, an OS version select and a status line that sets the submit button's reason.