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>
<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>
<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}>
<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> Configuration
| Property | Type | Description |
|---|---|---|
vertical | boolean | If true, renders each field on its own row. Default is false. |
columns | number | Number of columns in the grid layout. |
LabelsTopLayoutCell
Use LabelsTopLayoutCell to control column and row spanning for complex layouts:
<LabelsTopLayout columns={3}>
<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> | Property | Type | Description |
|---|---|---|
colSpan | number | Number of columns to span. |
rowSpan | number | Number of rows to span. |