Form

Lightweight, composable form wrapper with animated field-level error messages and full accessibility support.

Open in v0

Last updated: April 21, 2026

We will never share your email.

Installation

npx smoothui-cli add form

Features

  • Composable API: Form > FormField > FormLabel + FormControl + FormMessage
  • Animated error messages with spring entrance/exit (opacity + translateY)
  • aria-describedby links inputs to their error and description elements
  • aria-invalid="true" set on inputs when errors are present
  • Works standalone with simple validation or with react-hook-form
  • Composes with Checkbox, RadioGroup, Select, and native inputs
  • No forced dependency on any form library

Usage

import Form, { FormField, FormLabel, FormControl, FormMessage } from "@smoothui/form";

<Form errors={errors} onFormSubmit={handleSubmit}>
  <FormField name="email">
    <FormLabel>Email</FormLabel>
    <FormControl>
      <input type="email" />
    </FormControl>
    <FormMessage />
  </FormField>
</Form>

Accessibility

Keyboard Interactions

KeyDescription
TabMoves focus between form controls
EnterSubmits the form (native behavior)
SpaceActivates checkboxes and buttons within the form

ARIA Attributes

AttributeElementPurpose
aria-invalidInput (via FormControl)Set to true when the field has an error
aria-describedbyInput (via FormControl)References the description and/or error message element IDs
role="alert"FormMessageAnnounces error messages to screen readers

Reduced Motion

Error messages animate with a subtle opacity + translateY spring transition. When prefers-reduced-motion is enabled, messages appear and disappear instantly with zero duration.

Props

FormProps

FormFieldProps

FormLabelProps

FormMessageProps

On this page

Created by

Improved by

Edu Calvo's avatar

Powered by

motion.dev
Open source & free

Support SmoothUI

Help keep SmoothUI free and actively maintained. Every sponsor helps ship more components, blocks, and animation recipes.