Skip to main content
ninna-ui

FormGroup

FormGroup groups related form fields inside a semantic fieldset with an optional legend, description, spacing, and direction.

import { FormGroup } from "@ninna-ui/forms"
pnpm add @ninna-ui/forms

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

View source

Usage

Import and use FormGroup to semantically group related form fields inside a fieldset.

import { FormGroup, Field, Input } from "@ninna-ui/forms";
<FormGroup legend="Personal Information">
<Field label="First Name">
<Input placeholder="John" />
</Field>
<Field label="Last Name">
<Input placeholder="Doe" />
</Field>
</FormGroup>
<FormGroup
legend="Contact Details"
description="Please provide your contact information."
required
>
<Field label="Email" required>
<Input type="email" placeholder="john@example.com" />
</Field>
</FormGroup>

Basic

FormGroup with a legend and optional description.

Personal Information
Contact Details

Please provide your contact information.

Direction

Lay out fields vertically (default) or horizontally.

Vertical (default)
Horizontal

Spacing

Control the gap between fields with sm, md, or lg spacing.

Small Spacing
Medium Spacing (default)
Large Spacing

States

Required and disabled states propagate to all child fields.

Required Group*
Disabled Group

With Checkboxes & Radio

FormGroup works with any form control — checkboxes, radio groups, and more.

Notification Preferences

Choose how you want to be notified.

Shipping Method

Select your preferred shipping option.

API Reference

Complete list of props for the FormGroup component.

Props

PropTypeDefaultDescription
legendstring-Legend/title rendered inside the fieldset legend element
descriptionstring-Optional description text below the legend; linked via aria-describedby
disabledbooleanfalseDisables all form controls inside the fieldset
requiredbooleanfalseMarks the group as required (shows * indicator in legend)
spacing'sm' | 'md' | 'lg''md'Gap between child fields
direction'vertical' | 'horizontal''vertical'Layout direction of child fields
idstring-ID for the fieldset element (auto-generated if not provided)
classNamestring-Additional CSS classes
childrenReactNode-Form fields to group together

Accessibility

  • Renders a native fieldset element for semantic grouping of related controls
  • The legend prop renders a <legend> element — the primary accessible label for the group
  • The description prop is linked via aria-describedby for additional context
  • Setting disabled on the fieldset disables all child controls natively — no JavaScript needed
  • Setting required shows a visual indicator; pair with required on individual Field components for full a11y
  • All HTML attributes are forwarded via ...props spread — aria-label, role, etc. are fully overridable