Icons Control

Elementor Icons control displays Elementor’s Icon Library as well as allows SVG icons uploads. The control accepts include or exclude arguments to set a partial list of icons.

The control is defined in Control_Icons class which extends Control_Base_Multiple class.

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

Arguments

Name Type Default Description
type string icons 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 false Whether to display the label in a separate line.
separator string default  
default array   The default value is set as an array of value and library
fa4compatibility string   Used to Migrate data from old Icon control, Should be set to the old control name.
recommended array   Used to set the Recommended icons of this Control instance

Return Value

(array) An array containing Icon data:

  • $value (int) Icon.
  • $library (string) Media url.
[
	'value' => '',
	'library' => '',
]

Usage

<?php
class Icons_Control_Test_Widget extends \Elementor\Widget_Base {
	public function get_name() {
		return 'icons_test_widget';
	}

	public function get_title() {
		return __( 'Icons Test Widget', 'text-domain' );
	}

	protected function _register_controls() {
		$this->start_controls_section(
			'section_icon',
			[
				'label' => __( 'Icon', 'text-domain' ),
			]
		);

		$this->add_control(
			'icon',
			[
				'label' => __( 'Icon', 'text-domain' ),
				'type' => \Elementor\Controls_Manager::ICONS,
				'default' => [
					'value' => 'fas fa-star',
					'library' => 'solid',
				],
			]
		);

		$this->end_controls_section();
	}

	protected function render() {
		$settings = $this->get_settings_for_display();
		?>
		<div class="my-icon-wrapper">
			<?php \Elementor\Icons_Manager::render_icon( $settings['icon'], [ 'aria-hidden' => 'true' ] ); ?>
		</div>
		<?php
	}

	protected function _content_template() {
		?>

		<div class="my-icon-wrapper">
			{{{ iconHTML.value }}}
		</div>
		<?php
	}
}

Get The Latest Updates

We have a lot more where that came from! Join 830,093 subscribers who stay ahead of the pack.
By entering your email, you agree to our Terms of Service and Privacy Policy.