Skip to content
GitHub ↗

Forms / React + CSS

Email field

A visible label, a helpful hint, and an error that explains the next step.

Live preview

Use the address where you want to receive updates.

Make it yours

Place this field inside a form and validate on submit or blur. Browser validation helps users; validate again on the server before processing any real submission.

  1. Use a React project with CSS Modules support, such as Next.js or Vite.
  2. Save the JSX as EmailField.jsx and the CSS as EmailField.module.css in the same folder.
  3. Import EmailField and connect its props to your application. Controlled components need parent state and change handlers.

No third-party component or animation package is required. Use the theme controls to adjust accent, corners, spacing, and type. Copy the Theme CSS into your stylesheet and wrap your components in <div className="tdp-components">. The theme applies to every component inside that wrapper. TDP defaults work without a theme file.

Props

PropTypeUse
valuestringControlled email value.
onChangefunctionReceives the entered string.
errorstringValidation message, empty when valid.
labelstringVisible input label.

Accessibility & behavior

The label is connected with useId. The hint or error is linked through aria-describedby and aria-invalid reflects the error state. Do not use the placeholder as the only label.

Visible focus styles and reduced-motion support are included. Check labels, contrast, keyboard behavior, and screen-reader output again after adapting the component to your product.

Keep building