Skip to content
Block Controls

Units

Units control combines a numeric input with unit selection (px, %, em, etc.), perfect for spacing, sizes, and other CSS measurements.

Units Control

Control Settings

  • Units (units) - the units offered in the control's dropdown. The default list is px, %, em, rem, vw and vh

The field is a tag input. Type a unit and press Enter to add it. Whatever tags the field holds replace the default list outright rather than adding to it, and emptying the field leaves the control with no units at all.

Usage Examples

CSS Inline Styles

PHP
<div style="padding: <?php echo esc_attr( $attributes['control_name'] ); ?>">
    Content with custom padding
</div>
Handlebars
<div style="padding: {{control_name}}">
  Content with custom padding
</div>

Dynamic Margins

PHP
<div style="margin-top: <?php echo esc_attr( $attributes['control_name'] ); ?>">
    Content with custom top margin
</div>

Post Meta

Post Meta
<?php
$spacing = get_lzb_meta( 'control_meta_name' );
if ( $spacing ) {
    echo '<div style="gap: ' . esc_attr( $spacing ) . '">';
    echo '    Content with custom gap';
    echo '</div>';
}
?>

Common uses for Units control:

  • Padding and margins
  • Width and height
  • Font sizes
  • Border widths
  • Gap spacing

Was this article helpful?

Copyright © 2026 Lazy Blocks.