CxJS

LabelsTopLayout

import { LabelsTopLayout } from 'cx/ui'; Copied

LabelsTopLayout is used for dense forms with long labels or when labels are placed above inputs to save horizontal space. It renders children inside a table with two rows: one for labels and one for inputs.

<LabelsTopLayout mod="top">
  <TextField
    value={m.street}
    label="Address"
    placeholder="Street"
    style={{ width: "150px" }}
  />
  <TextField value={m.city} placeholder="City" style={{ width: "150px" }} />
  <TextField value={m.zip} placeholder="Zip" style={{ width: "70px" }} />
</LabelsTopLayout>

Set the width style on form fields to align inputs properly. Use LabeledContainer to group multiple widgets under a single label.

Vertical Mode

Set vertical to true to render each field on its own row:

<LabelsTopLayout vertical mod="top">
  <Select value={m.title} label="Title" style={{ width: "70px" }}>
    <option value="Mr">Mr.</option>
    <option value="Mrs">Mrs.</option>
  </Select>
  <TextField
    value={m.firstName}
    label="First Name"
    style={{ width: "150px" }}
  />
  <TextField value={m.lastName} label="Last Name" style={{ width: "150px" }} />
</LabelsTopLayout>

Multiple Columns

Use the columns property to arrange fields in a grid:

<LabelsTopLayout columns={3} mod="top">
  <TextField label="Field 1" value={m.field1} />
  <TextField label="Field 2" value={m.field2} />
  <TextField label="Field 3" value={m.field3} />
  <TextField label="Field 4" value={m.field4} />
  <TextField label="Field 5" value={m.field5} />
  <TextField label="Field 6" value={m.field6} />
</LabelsTopLayout>

Mods

ModDescription
topRemoves top padding from labels in the first row. Useful inside a Window or dialog where the default label padding creates unwanted spacing at the top.
stretchMakes the layout table stretch to full width.
fixedUses fixed table layout for equal column widths.

Configuration

PropertyTypeDescription
verticalbooleanIf true, renders each field on its own row. Default is false.
columnsnumberNumber of columns in the grid layout.

LabelsTopLayoutCell

Use LabelsTopLayoutCell to control column and row spanning for complex layouts:

<LabelsTopLayout columns={3} mod="top">
  <TextField label="Field 1" value={m.field1} />
  <TextField label="Field 2" value={m.field2} />
  <TextField label="Field 3" value={m.field3} />
  <LabelsTopLayoutCell colSpan={3}>
    <TextArea
      label="Notes"
      value={m.notes}
      rows={3}
      style={{ width: "100%" }}
    />
  </LabelsTopLayoutCell>
</LabelsTopLayout>
PropertyTypeDescription
colSpannumberNumber of columns to span.
rowSpannumberNumber of rows to span.