Skip to content
Docs/Field

Field

Form field wrapper for labels, inputs, and validation messages.

Usage

tsx
1import { Field, Input } from '@storm-ds/ui'
2
3<Field label="Email" htmlFor="email" required>
4 <Input id="email" type="email" placeholder="you@example.com" />
5</Field>

Basic

tsx
1<Field label="Name" htmlFor="name">
2 <Input id="name" placeholder="John Doe" />
3</Field>

Required Field

tsx
1<Field label="Email" htmlFor="email" required>
2 <Input id="email" type="email" />
3</Field>

With Description

This will be your public display name.

tsx
1<Field
2 label="Password"
3 htmlFor="password"
4 description="At least 8 characters"
5>
6 <Input id="password" type="password" />
7</Field>

With Error

Password must be at least 8 characters

tsx
1<Field
2 label="Username"
3 htmlFor="username"
4 error="Username already taken"
5>
6 <Input id="username" />
7</Field>

Props

PropTypeDefaultDescription
labelstring-Field label text
htmlForstring-ID of input for label association
requiredbooleanfalseShows required asterisk
errorstring-Error message text
descriptionstring-Helper text below field
childrenReact.ReactNode-Input component(s)
classNamestring-Custom classes

Use with AI

Create a Next.js component using Storm UI's Field for form field wrappers. Import: `import { Field, Input } from '@storm-ds/ui'`. Props: label (string), htmlFor (input ID), required (boolean), error (string), description (string), children (input), className. Wraps input with label, manages spacing, shows required asterisk, displays descriptions and error messages. Use for consistent form layouts. Label associates with input via htmlFor. Error message shows in destructive red. Description in muted text. Example: `<Field label="Email" htmlFor="email" required><Input id="email" /></Field>`, `<Field label="Name" description="Your full name"><Input /></Field>`, `<Field label="Username" error="Already taken"><Input /></Field>`