Skip to content
SENVENLI UI

Field

A label, hint and error row around any control, wired for screen readers; plus the label, description and error parts.
Around a native control
import {
  Field,
  FieldLabel,
  FieldDescription,
  FieldError,
} from "@senvenli/react/form";

Examples

Around an input group

The label, hint and error reach the group's input, not its frame.

With an error

The error replaces the hint and marks the control invalid; a library control draws that state itself.

Guidelines

When to use it

  • Wrapping a control the library does not provide, so it matches the other fields.

Use something else when

  • A text input is enough; it has the field row built in. Input

Accessibility

Built in

  • Label, hint and error are linked to the control with htmlFor, aria-describedby and aria-invalid.

You provide

  • A control with a matching id, or a single child Field can give one to.

API reference

Field

label
ReactNode
htmlFor
string

Control id for the label. Optional: when omitted, Field generates one and injects it onto a single-element child. Field is for a control the library does not provide (a native input, a third-party widget) and for InputGroup with InputGroupInput, which forwards it to its input. The library's own fields (TextField, Select…) carry their own label, hint and error, so they do not go inside a Field.

errorMessage
ReactNode

What went wrong and what to do; shown under the control and announced.

description
ReactNode

A line of help under the control (hidden while there is an error).

isRequired
boolean
requiredClassName
string

Class for the required "*" asterisk. Defaults to the danger text token; a brand marketing form can override it without forking this component.

childrenRequired
ReactNode
className
string

FieldLabel

childrenRequired
React.ReactNode
isRequired
boolean

Shows * in ds-text-danger (hidden from screen readers: the control is aria-required).

isOptional
boolean

Shows "(optional)" in the provider locale; use it when most fields of the form are required.

FieldDescription

childrenRequired
React.ReactNode

FieldError

children
React.ReactNode