Guide

Form Input Range

A slider input block that renders an <input type="range"> with configurable min, max, step, orientation, and output formatting. Displays the current value as a number, currency, or percentage. Supports optional label and min/max value labels.

Namespace

prc-block/form-input-range

Category

forms

Supports

FeatureValue
Anchortrue
Interactivitytrue
Layout (type)flex
Spacing (margin)true
Spacing (padding)true
Spacing (blockGap)true
Dimensions (minWidth)true
Bordertrue (custom selector: .range-container)
Color (text)true (custom selector: .range-container)
Color (background)true (custom selector: .range-container)
Typography (fontSize)true (custom selector: .range-container)
Typography (lineHeight)true (custom selector: .range-container)
HTMLfalse

Custom Selectors

{
  "root": ".wp-block-prc-block-form-input-range",
  "border": ".wp-block-prc-block-form-input-range .range-container",
  "typography": ".wp-block-prc-block-form-input-range .range-container",
  "color": ".wp-block-prc-block-form-input-range .range-container"
}

Attributes

AttributeTypeDefaultSourceDescription
displayLabelbooleantrueShow/hide the label above the slider.
labelstring""html (selector: label)Label text, editable via RichText.
minnumber0attribute (selector: input, attribute: min)Minimum slider value.
maxnumber100Maximum slider value.
stepnumber1Step increment between values.
valuenumber50Current/default slider value.
displayValuebooleantrueShow the formatted current value next to the slider.
displayMinMaxbooleanfalseShow min and max labels at the ends of the slider.
outputFormatstring"number"Format for the displayed value: "number", "currency", or "percentage".
orientationstring"horizontal"Slider orientation: "horizontal" or "vertical".
requiredbooleanfalseWhether a value must be set before form submission.
metadataobjectundefinedContains name (field identifier for form data).

Available Styles

None defined.

Inner Blocks

None. This is a leaf block.

Parent / Ancestor Requirements

No explicit parent constraint, but designed to function inside a prc-block/form container.

Usage Instructions

Basic Slider

  1. Insert the Range block.
  2. Type a label (e.g., "Budget").
  3. Set Min, Max, and Step in the inspector.
  4. Choose an Output Format (number, currency, or percentage).

Output Formats

FormatExample (value: 50)
number50
currency$50
percentage50%

Orientation

Set to "vertical" for a vertically-oriented slider. Default is "horizontal".

Min/Max Labels

Toggle Display Min/Max Labels to show the minimum and maximum values at each end of the slider.

Block Markup Example

<!-- wp:prc-block/form-input-range {"min":0,"max":1000,"step":10,"value":500,"outputFormat":"currency","metadata":{"name":"budgetRange"}} -->
<div class="wp-block-prc-block-form-input-range">
  <label>Budget</label>
  <div class="range-container">
    <input type="range" min="0" max="1000" step="10" value="500" />
    <output>$500</output>
  </div>
</div>
<!-- /wp:prc-block/form-input-range -->

PHP Rendering

The block uses server-side rendering via render_callback in class-form-input-range.php.

Render Pipeline

  1. Interactivity Setup: Adds data-wp-interactive with the target namespace (defaults to prc-block/form).
  2. Input Directives: Adds data-wp-on--input="actions.onInputRangeChange" to the <input> element for live value updates as the slider moves.
  3. Output Binding: Adds data-wp-text to the <output> element, binding it to a state getter that returns the formatted value (number/currency/percentage).
  4. Field Registration: Registers the field in the target form's formFields state via wp_interactivity_state() with the field name, current value, and outputFormat.

Frontend Interactivity

This block does not define its own interactivity store. It delegates to the parent form's prc-block/form namespace.

Form Actions Used

ActionDescription
onInputRangeChangeDefined in prc-block/form view module. Fires on every input event (live as slider moves). Reads the input's current value and updates the field in formFields. Also updates the <output> element text with the formatted value.

Value Formatting

The outputFormat attribute determines how the value is displayed:

  • "number": Raw numeric value
  • "currency": Prefixed with $ and formatted with toLocaleString()
  • "percentage": Suffixed with %

This formatting is applied both in the <output> element binding and when the value is stored in the form state.

BlockRelationship
prc-block/formParent form container. Provides the onInputRangeChange action and receives the slider value in formFields.

Was this helpful?