Unit Field

A number with its CSS unit.

The Unit field holds a number with its unit: a width, a font size, a gap.

Configuration

Go to Modern Fields > Fields groups and add the Unit field. Its settings are in the inspector:

Effect
UnitsThe units offered: px, em, rem, vw, vh and % by default.
Minimum valueThe lowest number allowed.
Maximum valueThe highest number allowed.
StepThe increment step of the field. 1 by default.
The Unit field settings

Display the value

The field stores the number and its unit together, such as 20px or 1.5rem: the value is ready to use in CSS. Read it with get_field():

PHP

Color Palette Field

Spacing Field


In this documentation