A configurable horizontal progress bar with label, value display, and animation support.
prc-block/progress-bar
media
| Feature | Enabled |
|---|---|
| Anchor | Yes |
| HTML | No |
| Interactivity | Yes |
| Animations | Yes |
| Color (background) | Yes (skip serialization) |
| Color (text) | Yes (skip serialization) |
| Spacing (blockGap) | Yes |
| Spacing (margin) | Yes |
| Spacing (padding) | Yes (default control) |
| Typography (fontSize) | Yes |
| Typography (lineHeight) | Yes |
| Typography (letterSpacing) | Yes |
| Typography (textTransform) | Yes |
| Typography (fontFamily) | Yes |
| Attribute | Type | Default | Description |
|---|---|---|---|
barColor |
string |
"social-trends-teal" |
Preset color slug for the filled portion of the progress bar. |
valueColor |
string |
"ui-black" |
Preset color slug for the value text. |
backgroundColor |
string |
"ui-beige-very-light" |
Preset color slug for the unfilled track background. |
barHeight |
number |
10 |
Height of the progress bar track in pixels. |
maxValue |
number |
100 |
The maximum value representing 100% progress. |
label |
string |
"Progress" |
RichText label displayed above/beside the bar. Source: html, selector: label. |
value |
number |
0 |
The current progress value. |
labelFormat |
string |
"percentage" |
How the value is displayed. One of: percentage, fractional. |
labelPosition |
string |
"left" |
Position of the label relative to the bar. One of: left, right. |
valuePosition |
string |
"outside" |
Position of the value text. One of: inside (within the bar fill), outside (after the bar). |
valueFontSize |
number |
12 |
Font size in pixels for the value text display. |
No block style variations defined.
None.
None.
- Insert the Progress Bar block.
- In the Inspector Panel > Data and Formatting:
- Set the Label text (also editable inline via RichText).
- Set Label Position to left or right.
- Adjust the Value slider (0 to max).
- Set the Maximum value to define the scale.
- Choose Value Position: inside the bar fill or outside.
- Choose Value Format: percentage (
35%) or fractional (35/100).
- In the Dimensions panel:
- Adjust the Bar Height (1-30px).
- In the Typography panel:
- Adjust the Value Font Size in pixels.
- In the Color panel:
- Set Bar Color (the filled portion).
- Set Value Color (the value text).
- Background and text colors are available via standard block supports.
<div class="wp-block-prc-block-progress-bar">
<label class="prc-progress-bar-label has-ui-black-color"
style="color: #000">Progress</label>
<div class="prc-progress-bar has-ui-beige-very-light-background-color"
style="background-color: #f7f5f2">
<div class="prc-progress-bar-value"></div>
<span class="prc-progress-bar-value-text" style="font-size: 12px"></span>
</div>
</div>The render_block_callback method:
- Generates a unique block ID via
wp_unique_id. - Stores the block's attributes in the interactivity state keyed by block ID via
wp_interactivity_state. - Uses
WP_HTML_Tag_Processorto augment the saved markup:- Sets the unique
id,data-wp-interactive, anddata-wp-contexton the wrapper. - Binds
data-wp-bind--styletostate.barStyleon the.prc-progress-bar-valueelement. - Binds
data-wp-texttostate.valueon the.prc-progress-bar-value-textelement.
- Sets the unique
Uses the WordPress Interactivity API (@wordpress/interactivity).
Store namespace: prc-block/progress-bar
State (derived):
barStyle-- Computes the inline style string for the bar fill:height: {barHeight}px; width: {percentage}%; background-color: var(--wp--preset--color--{barColor});value-- Returns the current value for the text display
The bar width and styling are dynamically computed from the interactivity state, allowing the value to be updated programmatically by other interactive blocks.
None.
{
"attributes": {
"label": "Progress",
"value": 35,
"maxValue": 100
}
}