Back to Tooljet

Field — Rocket Design Spec

frontend/src/components/ui/Rocket/Field/Field.spec.md

3.20.154-lts2.3 KB
Original Source

Field — Rocket Design Spec

<!-- synced: 2026-03-16 -->

Overview

Field is a composition wrapper for form controls. It provides label, description, error message, and layout (vertical/horizontal/responsive) around any Rocket input component.

Modular by design — Field wraps Input, Select, Textarea, DatePicker, etc. without duplicating label/validation logic.

Sub-components

Wrapped (token overrides)

Sub-componentPurposeToken override
FieldLayout containertw-gap-1.5 default spacing
FieldLabelLabel texttw-text-text-default tw-text-base tw-font-medium
FieldDescriptionHelper texttw-text-text-placeholder tw-text-sm
FieldErrorValidation messagetw-text-text-danger tw-text-sm
FieldGroupGroup containerPass-through (structural)

Re-exported from shadcn (no token overrides needed)

FieldContent, FieldSet, FieldLegend, FieldTitle, FieldSeparator

Props (Field)

PropTypeValuesDefault
orientationstringvertical | horizontal | responsivevertical
classNamestring

All other props forwarded to underlying div[role=group].

Composition Patterns

Basic field with input

jsx
<Field>
  <FieldLabel>Email</FieldLabel>
  <Input type="email" placeholder="[email protected]" />
</Field>

Field with description and error

jsx
<Field data-invalid="true">
  <FieldLabel>Password</FieldLabel>
  <Input type="password" aria-invalid="true" />
  <FieldDescription>Must be at least 8 characters.</FieldDescription>
  <FieldError>Password is too short.</FieldError>
</Field>

Field with InputGroup

jsx
<Field>
  <FieldLabel>Website</FieldLabel>
  <InputGroup>
    <InputGroupAddon>
      <InputGroupText>https://</InputGroupText>
    </InputGroupAddon>
    <InputGroupInput placeholder="example.com" />
  </InputGroup>
</Field>

Horizontal layout

jsx
<Field orientation="horizontal">
  <FieldLabel>Name</FieldLabel>
  <Input placeholder="John Doe" />
</Field>

Notes

  • data-invalid="true" on Field propagates error styling to children via group-data-[invalid=true].
  • data-disabled="true" on Field propagates disabled styling via group-data-[disabled=true].
  • FieldError accepts errors prop (array of { message }) for multi-error display.