Skip to content
v0.2.10

Field

The association between a visible label, its input and supporting messages.

Preview
Visible to your team.

Use Field

Field is a named export of @flood-md/react. Connect the package once, then import what you use.

First time here? Connect Flood
Example import style
field.tsxTSX
"use client";

import { FloodRoot, Field, Input } from "@flood-md/react";
import "@flood-md/react/styles.css";

export function Example() {
  return (
    <FloodRoot>
      <Field label="Project name" required hint="Visible to your team.">
        {(control) => <Input {...control} name="project" />}
      </Field>
    </FloodRoot>
  );
}

Design notes

  • Spread the supplied control props onto one Input or Textarea.
  • Field merges describedBy with hint/error IDs and forwards native required through its function child.
  • The host owns validation rules. Compose Field in a client component in Next.js.
  • Field is not a generic native div wrapper and does not forward a ref.

API reference

PropValuesDefault
status"error" | "warning" | "success" | "info"—
messageReactNode—
idstring—
labelReactNodeRequired
hideLabel · 0.2.3booleanfalse
hintReactNode—
errorReactNode—
requiredboolean—
describedBystring—
children(props: FieldControlProps) => ReactNodeRequired
View TypeScript source