Skip to main content
ninna-ui

FormControl

FormControl, FormLabel, and FormMessage components for building accessible forms with validation states.

import { FormLabel, FormMessage } from "@ninna-ui/forms"
pnpm add @ninna-ui/forms

Requires @ninna-ui/core (auto-installed) + CSS setup.

View source

Usage

FormControl provides context for form fields, managing required, invalid, and disabled states.

import { FormControl, FormLabel, FormMessage, Input } from "@ninna-ui/forms";
<FormControl isRequired>
<FormLabel>Email</FormLabel>
<Input type="email" placeholder="you@example.com" />
<FormMessage type="hint">We'll never share your email.</FormMessage>
</FormControl>
<FormControl isInvalid>
<FormLabel>Password</FormLabel>
<Input type="password" />
<FormMessage>Password must be at least 8 characters.</FormMessage>
</FormControl>

Basic

FormControl with FormLabel and FormMessage for validation feedback.

We'll never share your email.

With Different Sizes

FormControl works with inputs of any size.

Small size input

Medium size input

Large size input

API Reference

Complete list of props for FormControl, FormLabel, and FormMessage.

FormControl Props

Props

PropTypeDefaultDescription
idstring-Unique ID for the form field (auto-generated if not provided)
isRequiredbooleanfalseWhether the field is required
isInvalidbooleanfalseWhether the field is in an invalid state
isDisabledbooleanfalseWhether the field is disabled
isReadOnlybooleanfalseWhether the field is read-only

FormLabel Props

Props

PropTypeDefaultDescription
childrenReactNode-Label text content
classNamestring-Additional CSS classes

FormMessage Props

Props

PropTypeDefaultDescription
type'error' | 'success' | 'warning' | 'hint''error'Message type determines styling
childrenReactNode-Message content

Accessibility

  • FormLabel is automatically associated with the input via htmlFor
  • aria-required is set when isRequired is true
  • aria-invalid is set when isInvalid is true
  • aria-disabled is set when isDisabled is true
  • FormMessage is linked via aria-describedby