Skip to content

Form layout

A form can contain presentation elements which will not be part of the input.

Use Wrapper to give related fields a heading. In a longer order form, an Order details heading helps people find the SKU and quantity fields. You can add that section to an existing form without changing the field names or paths that later process steps use.

This example uses TextBlock to add instructions above the group. You can also use Divider to separate sections and Link to point people to supporting information.

import { NumberField, TextBlock, TextField, Wrapper } from "@pf/form-schema"
import { Schema } from "effect"
const orderForm = Schema.Struct({
instructions: TextBlock("Enter the SKU and quantity from the order."),
orderDetails: Wrapper(
{
sku: TextField({ label: "SKU" }),
quantity: NumberField({ label: "Quantity" }),
},
{ label: "Order details" },
),
})

Basic Form Demo dialog showing instructions above the Order details group, which contains the SKU and Quantity inputs.

The submission contains sku and quantity at the top level. The instructions and the orderDetails group are only part of the layout:

{
"sku": "CHAIR-001",
"quantity": 2
}

To submit an orderDetails object instead, use a nested Schema.Struct as shown in Form submission structure.

These components don’t add a value of their own to the submission.

Component Use it to
Wrapper Group related fields under a heading. The fields still submit at the surrounding level.
Divider Separate sections with a horizontal rule.
TextBlock Display fixed text, such as instructions.
DynamicTextBlock Display text resolved at runtime.
TextList Display a list of text items under a heading.
Image Display an image with optional alt text.
Link Display a text link to supporting information.
LinkButton Display a link styled as a button.
TableField Display read-only rows, such as previous shipments. Row field labels become column headings.
MetricBreakdown Display a breakdown of metric values.

For structures that change the submitted JSON, see Form submission structure.