Email Input React component for Tailwind CSS v4
v1.0.0Added in 1.5.0
A React email input for one address or a list of recipients, with domain completion, typo hints, contact suggestions and validation.
One address: type a name and after the @ a list completes the domain (emma@gm offers emma@gmail.com); Arrow Down and Up move through it, Enter or Tab takes the highlighted address, Escape closes it. Leaving the field checks the address: a malformed one shows the error, a likely typo shows "Did you mean emma@gmail.com?" with the fix as a button, and a valid one gets a green check. The error goes away as soon as the text is fixed. With multiple, every address becomes a chip with the person's initials or photo: type and press Enter, a comma, a semicolon or a space after a full address; pick a contact from the list by name or address; or paste a whole list like Emma Carter <emma@acme.com>, liam@acme.com; olivia@acme.com and every entry becomes a chip with its name, duplicates once (the existing chip pulses). A bad address stays as a red chip and the field says why; a likely typo turns its chip amber and the hint fixes it in one tap. Backspace in the empty text brings the last chip back as text to fix. Arrow Left at the start of the text moves onto the chips: Left and Right walk, Home and End jump, Delete or Backspace removes, Enter or F2 (or a double-click, or a second tap) edits, Cmd/Ctrl+C copies Name <address>, Escape returns to the text. Cmd/Ctrl+Enter adds the text and submits the form. On a phone the keyboard shows the email layout, text is 16px so iOS never zooms, the chip × buttons have a large touch area and the list stays in the page above the keyboard.
Email Input is a Pro React component in the React input components category, written in TypeScript for React 19 and Tailwind CSS v4. It installs as source with npx wingo-ui@latest add email-input, together with Avatar, Badge, Field, Listbox, useControllableState and 4 more and the npm packages motion and lucide-react.
Add to a project
Requirements: React 19 and Tailwind CSS v4, in Next.js (App Router or Pages), Vite or React Router. Installation guide · Next.js setup · Vite setup
npx wingo-ui@latest add email-inputEmail Input is part of Pro, with 298 more Pro items: $8 a month or $150 once. 14-day refund before you download any Pro item. See plans
Usage
Import EmailInput from @/components/ui/email-input.
import { useState } from "react"
import { EmailInput, type EmailContact } from "@/components/ui/email-input"
const CONTACTS: EmailContact[] = [
{ name: "Emma Carter", email: "emma@acme.com" },
{ name: "Liam Brooks", email: "liam@acme.com" },
{ name: "Olivia Bennett", email: "olivia.bennett@gmail.com" },
]
export function NewMessage() {
const [from, setFrom] = useState("")
const [to, setTo] = useState<string[]>(["emma@acme.com"])
return (
<div className="flex flex-col gap-4">
<EmailInput label="Your email" value={from} onValueChange={setFrom} name="from" required />
<EmailInput multiple label="To" value={to} onValueChange={setTo} contacts={CONTACTS} name="to" clearable />
</div>
)
}Props
multipledefaultfalsebooleanA list of recipients as chips; value becomes string[]. Off, the field holds one address as a string.
labeldefault""ReactNodeRenders the field anatomy around the box: the label above it, linked to the text input.
descriptiondefault""ReactNodeHelper text under the box. A typo hint takes its place while it shows; at the limit labels.limit(max) does when you pass none.
errordefault""ReactNodeReplaces the description with the animated error and marks the field invalid. Without it the field shows its own checks.
requireddefaultfalsebooleanThe red mark after the label and required / aria-required on the text input.
invaliddefaultfalsebooleanThe invalid look and aria-invalid without a message.
disableddefaultfalsebooleanDims the field, blocks typing and hides the × on chips.
readOnlydefaultfalsebooleanThe value stays visible and selectable but cannot change; chips stay focusable and copyable.
placeholderdefault"name@example.com"stringHint text while empty. Multiple mode defaults to Add people by name or email.
valuestring | string[]The address (single) or the addresses (multiple), controlled; pair it with onValueChange.
defaultValuedefault""string | string[]The starting value while uncontrolled: a string in single mode, a list in multiple mode. A form reset returns to it. The playground takes a comma-separated list in multiple mode.
onValueChange(value: string | string[]) => voidFires with the new text on every keystroke (single), or with the new list after every add, remove, fix and clear (multiple).
onChange(event: ChangeEvent<HTMLInputElement>) => voidThe native change event of the text input, untouched.
contactsdefault"[]"EmailContact[]People suggested while typing, matched by name, address or keywords (case and diacritics ignored). Chips of a known address show the name and photo.
domainsdefault"EMAIL_DOMAINS"string[]Completed after the @ and used for typo hints (gmail.com, outlook.com, yahoo.com, icloud.com...). [] turns both off.
allowedDomainsstring[]Only addresses at these domains are accepted (labels.domain names them); they also become the completions after the @.
validate(email: string) => (string | boolean)Extra rules after the format check: false marks the address invalid with the default message, a string with that message.
suggestTyposdefaulttruebooleanDid you mean emma@gmail.com? under the field for a likely typo in the domain (gmial.com, gmail.con, gmail without .com).
showValidIcondefaulttruebooleanSingle mode: a green check at the end once the address is valid and the field was left.
clearabledefaultfalsebooleanA clear button while there is a value: the text (Escape clears too) or every recipient.
maxdefault0numberMultiple mode: the most recipients. At the limit the text hides and the description reads labels.limit(max). 0 means no limit.
invalidEntriesdefault"keep""keep" | "reject"Multiple mode: keep a bad address as a red chip to fix later (like a mail app), or leave it in the text, shake and show why.
showAvatarsdefaulttruebooleanMultiple mode: the contact's photo or colored initials in each chip; the chips turn into pills.
leftIcondefault"<Mail />"ReactNodeSingle mode: the leading icon; null hides it.
sizedefault"md""sm" | "md" | "lg"Height 32 / 40 / 48px (md 44px on touch), 20 / 24 / 28px chips, 13 / 14 / 15px text (16px on phones). The multiple box grows as chips wrap.
variantdefault"soft""soft" | "outline" | "underline" | "ghost"The box look shared with every input.
radiusdefault"md""none" | "sm" | "md" | "lg" | "full"Box corners scaled with the size.
chipVariantdefault"soft""soft" | "outline" | "solid"Multiple mode: the Badge variant of the chips.
tonedefault"neutral""neutral" | "brand" | "success" | "warning" | "danger" | "info"Multiple mode: the color of valid chips. Bad addresses are always danger, likely typos warning.
colordefault""stringAny CSS color for valid chips; replaces the tone.
namedefault""stringSingle mode: the input's name. Multiple mode: one hidden input per address, so FormData.getAll(name) returns the list.
labelsPartial<EmailInputLabels>Copy merged over the English defaults: invalid, invalidEntry(email), invalidCount(n), domain(domains), didYouMean(fix), useSuggestion(email), recipient(label, email), remove, added, removed, duplicate, limit(max), copied(email), clear, suggestions.
onReject(email: string, reason: "invalid" | "duplicate" | "limit" | "domain") => voidCalled for every address that was turned away or flagged.
fieldPropsPartial<FieldProps>Anything else for the Field wrapper: optional, labelAction, orientation, labelWidth, hideLabel.
refRefObject<HTMLInputElement | null> or (node) => voidThe text input. Every other native prop lands there too: autoFocus, autoComplete, enterKeyHint, onBlur, onKeyDown (runs first), aria-*, data-*.
classNamesPartial<Record<"field" | "label" | "description" | "error" | "counter" | "root" | "box" | "icon" | "input" | "chip" | "valid" | "clear" | "hint" | "suggestions" | "list" | "option", string>>Extra classes for the parts: the field anatomy, the box, the icon, the text input, each chip, the valid check, the clear button, the typo hint and the suggestions panel.
classNamestringClasses for the outermost element: the Field root when there is a label, description or error, else the email input root.
Parts
isValidEmail
functionThe format check the field uses: one @, a sensible local part and a domain with a TLD of 2 or more letters, 254 characters at most.
emailstringThe address to check.
returnsbooleantrue when the format is valid.
normalizeEmail
functionTrims, drops mailto: and angle brackets and lowercases the domain. The field runs it on every address it keeps.
suggestEmailFix
functionThe typo check behind the hint: emma@gmial.com gives emma@gmail.com, liam@acme.con gives liam@acme.com, and null when nothing looks wrong.
emailstringThe address to check.
domainsdefault"EMAIL_DOMAINS"string[]The known domains to compare against.
returnsstring | nullThe corrected address, or null.
parseEmailList
functionSplits a pasted list on commas, semicolons, tabs and new lines (quotes and <> respected) into { email, name? } entries: "Emma Carter <emma@acme.com>, liam@acme.com".
EMAIL_DOMAINS
constantThe default domains completed after the @ and used for typo hints: gmail.com, outlook.com, yahoo.com, icloud.com, hotmail.com, proton.me and more.
EmailContact
typeA suggested person: { email, name?, avatar?, keywords? }.
EmailEntry
typeOne parsed entry from parseEmailList: { email, name? }.
EmailInputLabels
typeEvery string the field shows or announces, for the labels prop.
Examples
Sign up
One address with domain completion, a typo hint, the valid check and a form submit.
Compose
To and Cc with contacts suggested by name or address.
Paste a list
invalidEntries keep (red chips) next to reject (text stays and shakes).
Company only
allowedDomains, max={5} and brand chips in a pill box.
Styles
Sizes, box variants, chip variants, tones, no avatars and a custom color.
States
A server error, read only and disabled.
Dependencies
Files
- components/ui/email-input.tsx
FAQ
Is the React Email Input component free?
The preview, props and docs are free; copying the source needs a Pro plan. See plans.
How do I install Email Input?
Run npx wingo-ui@latest add email-input. It also adds the Wingo UI items it builds on (Avatar, Badge, Field, Listbox, useControllableState and 4 more) and the npm packages motion and lucide-react. With shadcn, add the @wingo-ui registry with your API key, then run npx shadcn@latest add @wingo-ui/email-input.
How does Email Input behave on phones?
On a phone the keyboard shows the email layout, text is 16px so iOS never zooms, the chip × buttons have a large touch area and the list stays in the page above the keyboard.
See also
Used in
More React input components
Articles using this component
- React Tag Input: Chips from Typing, Paste and Suggestions
Component guides8 min read
New components by email
New posts, product news and occasional offers from Wingo UI. We count clicks to keep it relevant.