Elementor dimensions control displays a input fields for top, right, bottom, left and the option to link them together.

The control is defined in Control_Dimensions class which extends Control_Base_Units class.

Note that when using the control, the type should be set using the \Elementor\Controls_Manager::DIMENSIONS constant.


Name Type Default Description
type string dimensions The type of the control.
label string The label that appears above of the field.
description string The description that appears below the field.
show_label bool true Whether to display the label.
label_block bool true Whether to display the label in a separate line.
separator string default Set the position of the control separator. Available values are default, before, after and none. default will position the separator depending on the control type. before / after will position the separator before/after the control. none will hide the separator.
placeholder string The field placeholder that appears when the field has no values.
allowed_dimensions array|string all Which fields to show. Available values are all, horizontal, vertical or an array [ 'top', 'right', 'bottom', 'left' ].
default array [
‘top’ => ”,
‘right’ => ”,
‘bottom’ => ”,
‘left’ => ”,
‘isLinked’ => true,
Default dimensionsvalue.

  • $top (int) Top dimension.
  • $right (int) Right dimension.
  • $bottom (int) Bottom dimension.
  • $left (int) Left dimension.
  • $unit (string) The CSS unit type.
  • $isLinked (bool) Whether to link all the values together or not.

Return Value

(array) An array containing the dimension values:

	'top' => '',
	'right' => '',
	'bottom' => '',
	'left' => '',
	'unit' => '',
	'isLinked' => '',


class Elementor_Test_Widget extends \Elementor\Widget_Base {

	protected function _register_controls() {

				'label' => __( 'Content', 'plugin-name' ),
				'tab' => \Elementor\Controls_Manager::TAB_CONTENT,

				'label' => __( 'Margin', 'plugin-domain' ),
				'type' => Controls_Manager::DIMENSIONS,
				'size_units' => [ 'px', '%', 'em' ],
				'selectors' => [
					'{{WRAPPER}} .your-class' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',



	protected function render() {
		$settings = $this->get_settings_for_display();
		echo '<div class="your-class"> ... </div>';

	protected function _content_template() {
		<div class="your-class"> ... </div>