Skip to main content

Number

Type: number

Description

Numeric input field with optional min/max constraints.

Screenshot

Number

Basic Usage

[
"type" => "number",
"heading" => __("Field Label", "your-text-domain"),
"param_name" => "your_param_name",
"value" => 0,
"settings" => [
"min" => 0,
"max" => 100,
"step" => 1,
],
"description" => __("Field description", "your-text-domain"),
]

Common Parameters

All param types support these common parameters:

ParameterTypeDescription
typeStringRequired. Must be "number"
holderStringHTML tag name where the value is displayed in backend edit mode. Default: hidden input
classStringCSS class added to the holder HTML tag
headingStringLabel shown in the editor interface
param_nameStringRequired. Parameter name used in shortcode
valueMixedValue for the parameter
descriptionStringHelp text shown below the field
groupStringTab/group name to organize parameters
sectionStringSection slug to visually group params within a tab
weightIntegerDisplay order (higher = shows first)
edit_field_classStringCSS class for field width (e.g., "vc_col-sm-6")
dependencyArrayShow/hide based on other field values
admin_labelBooleanShow value in element title bar
param_holder_classStringCSS class for the param wrapper in the edit element modal
save_alwaysBooleanForce saving the value even if it equals the default or is empty
callbackArrayJavaScript function callback (e.g., ['after_add' => 'myCallback'])
settingsArrayType-specific configuration options (see Type-Specific Parameters below)
deprecatedStringVersion in which the param was deprecated

Type-Specific Parameters

ParameterTypeDefaultDescription
settingsArray-Configuration array with the following options:
    minInteger-Minimum allowed value
    maxInteger-Maximum allowed value
    stepInteger-Step increment value
    placeholderInteger-Placeholder value shown when empty
    unitsBoolean|ArrayfalseEnable CSS unit selector. Set to true for default units (px, em, rem, vw, vh, %) or provide a custom array (e.g., ['px', 'em', '%']). When enabled, the saved value includes the unit suffix (e.g., "10px")
    default_unitStringFirst unit in listThe unit selected by default when no unit is present in the value

Complete Example

<?php
add_action('vc_before_init', 'my_element_with_number');
function my_element_with_number() {
vc_map([
"name" => __("My Element", "domain"),
"base" => "my_element",
"category" => __("My Category", "domain"),
"params" => [
[
"type" => "number",
"heading" => __("Items Count", "domain"),
"param_name" => "items_count",
"value" => 10,
"settings" => [
"min" => 0,
"max" => 100,
"step" => 5,
],
"description" => __("Number of items to display", "domain"),
],
[
"type" => "number",
"heading" => __("Margin Top", "domain"),
"param_name" => "margin_top",
"value" => "20px",
"settings" => [
"min" => 0,
"max" => 200,
"step" => 1,
"units" => ['px', 'em', '%'],
"default_unit" => 'px',
],
"description" => __("Top margin with unit selector", "domain"),
],
],
]);
}