Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Minimal Contact Form Block for React

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.

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 minimal contact form for React with Base UI: no card, no frame, only the page's rails and top rule. A centred heading and one sentence sit over three fields (name, email and a message with a live counter out of 400) and a full-width Shine Button. Each field checks itself when you leave it, and corrects itself while you fix it; submitting checks the rest and moves focus to the first problem. A valid message turns into a single line of thanks in the same space, which takes focus, with a way to write another. It's built from Field, Input, Textarea, Guides, Shine Button and Button, with CSS transitions for the entrances. For apps, tools and sites that want a form and nothing else.

FAQ

When does a field show its problem?

Leaving a field that has something in it checks it, so a half-typed email is flagged as you tab away, not after you try to send. A field you haven't touched, or left empty, waits for the submit. While a message is showing, typing re-checks it: it changes to the next problem or goes away the moment the field is valid. Typing never raises a new message by itself.

How does the counter work?

The textarea has maxLength set to 400, so it stops there, and the counter under it shows what's typed. The counter is the field's description, so a screen reader hears "12 / 400 characters" when the field takes focus, not on every key. In the last 40 characters it turns to the full text colour and weight. Change LIMIT to move the cap and SHORTEST for the shortest message the check accepts.

Where does the form send its data?

Nowhere yet. The submit handler waits 800 milliseconds, as a stand-in for a request, then shows the thanks. Replace that timer in submit with your own call (your inbox, a form endpoint or a help desk): details holds the name, email and message.

What does the thank-you say, and who hears it?

It names the visitor by first name and repeats the address the reply will go to, so a typo is easy to spot. It is a status region that takes focus when it appears, so a screen reader reads it at once. "Write another" brings back an empty form and puts focus on the heading.

How does it fit on a phone?

The form is already one column, so it only narrows: the heading wraps and nothing scrolls sideways at 320 pixels. The heading and the form fade up once on load; with reduced motion they simply appear.

  • Pro

    A card-in-card contact section for a bookkeeping service: the details of the desk you pick beside a raised form with a live message counter.

  • Pro

    A talk-to-sales split for a scheduling platform: what happens next as three numbered steps and a band of contact details beside a form that checks itself, shows each problem under its field and confirms in place.

  • Pro

    A hero-sized contact section for an architecture practice: a tinted band with a large headline and three ways to reach the studio, and a raised form panel that overlaps the band's lower edge.

  • Pro

    Light Email Capture CTA

    Forms and capture

    A newsletter CTA as a band between solid rails: a headline and a sentence at the start, and at the end one Shine Button that opens in place into an email field with its own Shine submit, closes on Escape and ends in a confirmation.

  • 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 contact split for a design studio: a tall tinted panel of email, phone and address with a copy button each, hours and profile links, beside a raised brief form.