WidgetCoreWidgetCore Documentation

Counter widget

The complete guide to the WidgetCore Counter widget — starting and ending numbers, animation duration, prefix and suffix, title and description, reduced motion and every style control.

The Counter widget animates a number from a starting value to an ending value — once, when the widget scrolls into view. It is built for stats like “1200 active students” or “98% satisfaction”.

ItemValue
Widget namewgcr-counter
Panel titleCounter
CategoryWidgetCore Widgets (wgcr)
Style / scriptwgcr-counter / wgcr-counter
Root class.wgcr-counter

The “Counter” section

ControlIDTypeDefaultNotes
Starting numberstart_numNumber0The animation starts here
Ending numberend_numNumber100The target number
Animation duration (ms)durationNumber1500100–10000 in the control, capped at 10000 in the output

The “Texts” section

ControlIDTypeDefaultNotes
Number prefixprefixTextEmptyPrinted before the number, for example “+”
Number suffixsuffixTextEmptyPrinted after the number, for example “%”
TitletitleText“Active students”Shown under the number
DescriptiondescriptionTextarea“A short note about this stat…”Shown under the title
Title tagtitle_tagSelectH3H2 to H6 or DIV

Empty parts (prefix, suffix, title, description) are not printed at all.

HTML output

html
<div class="wgcr-counter">
  <div class="wgcr-counter-row">
    <span class="wgcr-counter-affix">+</span>
    <span class="wgcr-counter-num" data-start="0" data-end="100" data-duration="1500">100</span>
    <span class="wgcr-counter-affix">students</span>
  </div>
  <h3 class="wgcr-counter-title">Active students</h3>
  <p class="wgcr-counter-desc">A short note about this stat…</p>
</div>
ClassPurpose
.wgcr-counterWidget root
.wgcr-counter-rowThe row of prefix + number + suffix
.wgcr-counter-affixA prefix or suffix text part
.wgcr-counter-numThe number itself, carrying data-start, data-end and data-duration for the script
.wgcr-counter-title / .wgcr-counter-descTitle and description

Animation behaviour

  • The number in the HTML is the ending number from the start, so with JavaScript off the correct value is still shown and nothing is lost for crawlers.
  • The script waits with an IntersectionObserver (threshold 0.3) until the widget is visible, then counts from start to end with a cubic ease-out curve and sets data-done="1" when finished; the animation never runs twice — not even when the counter sits inside tabs and is shown and hidden repeatedly.
  • Without IntersectionObserver support the animation runs immediately.
  • With prefers-reduced-motion: reduce the ending number is written directly, without movement.

Style sections

  • Number: “Number color”, the number typography, “Prefix and suffix color” and “Number parts gap”.
  • Title and description: “Title color”, “Description color”, both typographies and “Gap between texts”.
  • General: “Horizontal alignment” (start / center / end) and a ready-made box group (background, border, shadow, padding, radius).

Custom style example

css
/* A bigger number in the brand color */
.wgcr-counter .wgcr-counter-num { font-size: 64px; color: #2e86de; }
.wgcr-counter .wgcr-counter-title { margin-top: 8px; }