Atoms / Field

Field

A label, a control, a hint and an error, tied together.

import { Field, Input } from "@forgeron/ui";
/01 → Default

Shown to everyone you invite.

import { Field, Input } from "@forgeron/ui";

export default function Default() {
  return (
    <div style={{ width: 320 }}>
      <Field label="Workspace name" hint="Shown to everyone you invite.">
        {(control) => <Input {...control} defaultValue="Atelier Moreau" />}
      </Field>
    </div>
  );
}
/02 → Hint and error

Shown to everyone you invite.

This name is taken. Try another one.

import { Field, Input } from "@forgeron/ui";

export default function Default() {
  return (
    <div style={{ display: "grid", gap: 20, width: 320 }}>
      <Field label="Workspace name" hint="Shown to everyone you invite.">
        {(control) => <Input {...control} defaultValue="Atelier Moreau" />}
      </Field>
      <Field label="Subdomain" error="This name is taken. Try another one.">
        {(control) => <Input {...control} mono defaultValue="atelier" />}
      </Field>
    </div>
  );
}
API → Props
PropTypeDefaultDescription
labelReactNode—Above the control.
hintReactNode—Help under the control.
errorReactNode—What happened, then what to do.
children(control) => ReactNode—Spread `control` on the input: id, aria-describedby, aria-invalid.
classNamestring—Extra classes.