The Number option is a control that adds a numeric input field to your custom widget. It allows users to enter and adjust numerical values, often with controls to set minimums, maximums, and increments.
Why would someone use it in a custom widget? #
You use a Number control anytime your widget’s functionality depends on a numeric value. This is essential for settings like quantities, sizes, ratings, counts, or any parameter where you need precise numerical input instead of plain text.
Where This Option Appears #
- In Widget Builder: You add and configure this control in the Content tab of the Widget Builder interface, just like the Text control.
- In the Elementor Editor: Once saved, it appears as a number input field (often with increment/decrement arrows) within your widget’s settings panel in Elementor. The value entered here can control anything from sizes and counts to interactive logic.
Available Settings #
Based on the provided screenshots, here are the configurable settings for the Number control:
Basic Settings (Content Tab) #
- Label: The name of the control shown in the editor (e.g., “Item Count”, “Font Size”, “Rating”).
- Name: The unique machine-readable ID (like
item_countorrating_value) used to create the dynamic shortcode. - Description: Optional text that appears below the field to provide context or instructions.
- Placeholder: Example number shown in the empty field (e.g., “5”).
- Min (Minimum Value): The smallest number allowed. Prevents users from entering a value lower than this.
- Max (Maximum Value): The largest number allowed. Prevents users from entering a value higher than this.
- Step (Step Increment): Defines the amount the value changes with each click of the input’s arrows. A step of
1allows whole numbers (1,2,3), while0.1allows decimals (1.0, 1.1, 1.2). - Default Value: The number that pre-populates the field when the widget is first used.
Advanced Settings (Advanced Tab) #
- Show Label: Toggles the control’s label on or off in the editor.
- Label Block (
Display Label): Makes the label take the full width of the panel on its own line. - Responsive Control: Allows setting different numeric values for desktop, tablet, and mobile views.
- Dynamic Support: When enabled, this number can be populated dynamically from WordPress sources (e.g., a custom field containing a post’s view count or a product’s price).
- Frontend Available: When enabled, the numeric value is passed to your widget’s frontend JavaScript for use in calculations or interactive functions.
- Separator: Adds a visual line (
None,Top,Bottom,Both) to group this control with others. - Conditions: Allows you to show or hide this number field based on the value of other controls.
- Control Classes: Lets you add custom CSS classes to the control’s wrapper in the editor panel for custom styling.
Generated Shortcode #
When you add a Number control with the Name item_count, Widget Builder generates the dynamic shortcode: {{item_count}}.
- What it represents: This shortcode is a placeholder for the actual numeric value entered in the Elementor editor.
- Where to use it:
- HTML Panel: Use it to output the number directly (e.g.,
<span class="count">{{item_count}}</span> items). - CSS Panel: Most commonly used here to apply dynamic numerical values, often via CSS custom properties for sizes, spacing, or other properties (e.g.,
width: calc({{item_count}} * 10px);). - JS Panel: If “Frontend Available” is enabled, access the value in JavaScript for scripts, animations, or calculations.
- HTML Panel: Use it to output the number directly (e.g.,
How to Use It: A Practical Example #
Let’s create a simple “Progress Bar” where users can set the completion percentage.
- In Widget Builder’s Content tab, add a Number control.
- Set the Label to
Progress Percentageand the Name will auto-fill asprogress_percentage. - Set Min to
0, Max to100, and Step to1. - Set a Default Value:
75. - In your HTML panel, create a container:
<div class="progress-bar"><div class="progress-fill"></div></div>. - In your CSS panel, style
.progress-fillwith a dynamic width:width: {{progress_percentage}}%;.
Now, in Elementor, users can drag in your widget and adjust the “Progress Percentage” number from 0 to 100, and the bar’s width will update visually.
Common Use Cases #
- Sizing & Spacing: Control dynamic widths, heights, margins, or paddings (e.g., custom spacer height, icon size).
- Counters & Stats: Set initial values for animated number counters, ratings, or item counts.
- Slider & Carousel Settings: Control the number of slides to show, scroll speed, or auto-play delay.
- Dynamic Calculations: Use as a parameter in formulas for pricing tables, estimators, or interactive tools.
Helpful Tips #
- Use Min/Max for Safety: Always set sensible minimum and maximum values to prevent users from breaking the layout with implausible numbers (like a
-100margin). - Smart Step Values: For pixel-based sizes, a step of
1is fine. For opacity or scaling, use a step of0.1for finer control. - Combine with CSS Calc(): For powerful dynamic layouts, use the shortcode inside the CSS
calc()function (e.g.,flex-basis: calc({{column_width}}% - 20px);). - Enable Frontend for Interactivity: If your widget’s JavaScript needs to react to the number (like a live price calculator), remember to check the Frontend Available and Dynamic Support boxes for full flexibility.
Frequently Asked Questions #
What is the Number control in Widget Builder?
The Number control adds a numeric input field to your custom widget, letting users enter and adjust numerical values with optional minimum, maximum, and increment controls. You add it in the Content tab, and in Elementor it appears as a number input, often with increment and decrement arrows. It is ideal for settings like quantities, sizes, ratings, and counts where precise numeric input is needed instead of plain text.
How do I restrict the values a user can enter?
Use the Min and Max settings to set the smallest and largest numbers allowed, which prevents users from entering values outside that range. The Step setting controls how much the value changes with each click of the input arrows; a step of 1 allows whole numbers while 0.1 allows decimals. Setting sensible Min/Max values helps avoid layout-breaking inputs like a -100 margin.
Where can I use the Number control’s shortcode?
A Number control named item_count generates the shortcode {{item_count}}, a placeholder for the value entered in Elementor. You can output it directly in the HTML panel, such as {{item_count}} items, or use it in the CSS panel for dynamic sizing like width: {{progress_percentage}}%. If Frontend Available is enabled, you can also read it in the JS panel for scripts and calculations.
Can the Number value be used in CSS calculations?
Yes. The shortcode works inside the CSS calc() function for powerful dynamic layouts, for example flex-basis: calc({{column_width}}% – 20px) or width: calc({{item_count}} * 10px). This makes the Number control well suited for controlling widths, heights, margins, paddings, and spacing that should respond to a value the editor sets.
Does the Number control support dynamic and responsive values?
Yes. Enable Dynamic Support so the number can be populated from WordPress sources, such as a custom field holding a post’s view count or a product’s price. Enable Responsive Control to set different numeric values for desktop, tablet, and mobile, and enable Frontend Available when your JavaScript needs to react to the number, for example in a live price calculator.
