# Elements: Form layout, further examples

> Plainkit 0.28.0. Generated by scripts/build-skills.mjs from core/dist/elements/api.full.json. Do not edit: change the source and run the generator.

The element sections in `elements-form-layout.md` show the first example of each element; these are the rest.

## `pk-field`

Example: Error and inline label

```html
<pk-field label="SKU" error="SKU cannot contain spaces."><pk-input value="bad sku"></pk-input></pk-field>
<pk-field label="Weight" layout="row"><pk-input value="6.4"></pk-input></pk-field>
```

Example: Action beside the label

```html
<pk-field label="Release date" help="Copied from the source record."><pk-button slot="label-action" variant="ghost" size="mini">↺ Source</pk-button><pk-input value="2026-10-14"></pk-input></pk-field>
```

## `pk-field-group`

Example: Inline: a short add-row, the fields at their own width with the buttons in the end slot

```html
<pk-field-group label="Add line" layout="inline" fields='[{"key":"sku","label":"SKU","cols":6},{"key":"qty","label":"Quantity","kind":"number","cols":2}]'><pk-button slot="end" variant="primary">Add</pk-button><pk-button slot="end" variant="ghost">Cancel</pk-button></pk-field-group>
```

Example: Fields with a conditional one (set fields and values from script: an inline script cannot run under this site's CSP)

```html
<pk-field-group label="Order" fields='[{"key":"name","label":"Name","required":true},{"key":"qty","label":"Quantity","kind":"number","min":"1"},{"key":"status","label":"Status","kind":"select","options":[{"value":"open","label":"Open"},{"value":"closed","label":"Closed"}]},{"key":"note","label":"Closing note","kind":"textarea","required":true,"when":{"field":"status","equals":"closed"}},{"key":"amount","label":"Amount","kind":"number","format":"money","decimals":2,"currency":"USD"}]' values='{"status":"open"}'></pk-field-group>
```

Example: Declarative conditions: Paid on shows while the status is paid, the reference is required above 100 and disabled when void, the memo is read-only once paid (no server round trip)

```html
<pk-field-group label="Invoice" fields='[{"key":"status","label":"Status","kind":"select","options":[{"value":"open","label":"Open"},{"value":"paid","label":"Paid"},{"value":"void","label":"Void"}]},{"key":"amount","label":"Amount","kind":"number"},{"key":"paidon","label":"Paid on","kind":"date","whenExpr":"status == \u0027paid\u0027"},{"key":"ref","label":"Reference","requiredExpr":"amount > 100","disabledExpr":"status == \u0027void\u0027"},{"key":"memo","label":"Memo","readonlyExpr":"status in [\u0027paid\u0027, \u0027void\u0027]"}]' values='{"status":"open"}'></pk-field-group>
```

Example: Conditional text: the label and the help tooltip follow the status (labelWhenExpr, helpWhenExpr)

```html
<pk-field-group label="Invoice" fields='[{"key":"status","label":"Status","kind":"select","options":[{"value":"open","label":"Open"},{"value":"paid","label":"Paid"}]},{"key":"due","label":"Due date","kind":"date","labelWhenExpr":"status == \u0027paid\u0027 ? \u0027Paid on\u0027 : \u0027Due on\u0027","helpWhenExpr":"status == \u0027paid\u0027 ? \u0027The day the money arrived.\u0027 : \u0027The day payment is expected.\u0027"}]' values='{"status":"open"}'></pk-field-group>
```

Example: Twelfths of the row: cols sizes each field (Quantity 2, Grade 2, Released 3, Price 3), two per row on a phone

```html
<pk-field-group label="Release" fields='[{"key":"qty","label":"Quantity","kind":"number","cols":2},{"key":"grade","label":"Grade","cols":2},{"key":"date","label":"Released","kind":"date","cols":3},{"key":"price","label":"Price","kind":"number","cols":3},{"key":"title","label":"Title"}]'></pk-field-group>
```

Example: Short fields share a row: columns=3, columnSpan=2 for Name, span for the Note; datetime-local holds yyyy-MM-ddTHH:mm, no time zone

```html
<pk-field-group label="Booking" columns="3" fields='[{"key":"name","label":"Name","columnSpan":2},{"key":"unit","label":"Unit","kind":"select","options":[{"value":"cm","label":"cm"},{"value":"in","label":"in"}]},{"key":"start","label":"Starts","kind":"datetime-local","required":true},{"key":"end","label":"Ends","kind":"datetime-local"},{"key":"n","label":"Guests","kind":"number"},{"key":"note","label":"Note","kind":"textarea","span":true}]' values='{"start":"2026-10-14T09:30"}'></pk-field-group>
```

Example: A custom field: your own content in the field body (slot editor-<key>), no value and no part in the form

```html
<pk-field-group label="Order" fields='[{"key":"name","label":"Name"},{"key":"sum","label":"Summary","kind":"custom"}]' values='{"name":"Acme"}'><span slot="editor-sum">3 lines, total 45.00</span></pk-field-group>
```

## `pk-record-form`

Example: Sections tagged by tab: two columns on desktop, one tab at a time on a phone

```html
<pk-record-form tabs-from="phone">
  <pk-tabs slot="tabs" value="details">
    <pk-tab value="details">Details</pk-tab>
    <pk-tab value="pricing">Pricing</pk-tab>
  </pk-tabs>
  <form>
    <pk-stack>
      <div tab="details"><pk-card heading="Details"><pk-field label="Name"><pk-input name="name"></pk-input></pk-field></pk-card></div>
      <div tab="pricing"><pk-card heading="Pricing"><pk-field label="Price"><pk-input name="price"></pk-input></pk-field></pk-card></div>
    </pk-stack>
  </form>
  <div slot="sidebar" tab="details"><pk-card heading="Status"><pk-badge variant="ok">Active</pk-badge></pk-card></div>
</pk-record-form>
```

Example: Tabs as data: a count badge, and a tab left out

```html
<pk-record-form tabs-from="always" tabs='[{"value":"details","label":"Details"},{"value":"orders","label":"Orders","count":3},{"value":"audit","label":"Audit","visible":false}]'>
  <form>
    <pk-stack>
      <div tab="details"><pk-card heading="Details"><pk-field label="Name"><pk-input name="name"></pk-input></pk-field></pk-card></div>
      <div tab="orders"><pk-card heading="Orders">Recent orders</pk-card></div>
    </pk-stack>
  </form>
</pk-record-form>
```
