size

CSS length input with a unit dropdown (px, em, rem, %, vh, vw). Stores a single CSS-ready string you can drop straight into `style`.

Stored value

string — a CSS length like `"16px"`, `"1.5rem"`, `"100%"`. Empty string when unset.

Supports

  • Numeric input + unit selector via WP's `UnitControl`
  • Supported units: px, em, rem, %, vh, vw
  • Plain-text fallback when `UnitControl` isn't available

Config options

helpTextstring
One-line description shown below the input.

Example

json
{ "id": "ctrl_width",
  "type": "size",
  "label": "Container width",
  "attributeKey": "container_width",
  "default": "960px",
  "parentPanelId": "panel" }

Gotchas

Heads up
Stored value is a CSS string, not a number — pass it directly to `style.width` / `style.padding` in React, or echo it inside a `style` attribute in PHP.
Heads up
For spacing-scale presets (None / S / M / L) use `spacing` instead — `size` is for free-form CSS lengths.