Skip to content

Count To

dvk-count-to renders an animated numeric metric with optional prefix, suffix, thousands separator, and decimal formatting.

Total Throughput

html
<dvk-count-to
  end-val="987654.32"
  decimals="2"
  prefix="$"
  suffix="M"
  duration="1800"
></dvk-count-to>

Props

NameTypeDefaultNotes
start-valnumber0Initial value used when the counter starts or restarts.
end-valnumber0Target value displayed after the count animation finishes.
durationnumber2000Animation duration in milliseconds.
delaynumber0Delay before the animation starts, in milliseconds.
decimalsnumber0Number of decimal places to render.
decimalstring.Decimal separator.
separatorstring,Thousands separator.
prefixstringemptyText rendered before the number when no prefix slot is provided.
suffixstringemptyText rendered after the number when no suffix slot is provided.
disabledbooleanfalseDisables animation and immediately renders the target value.
transitionlinear | easeOutCubic | easeInOutCubic | easeOutExpoeaseOutExpoEasing preset for the count animation.

Events

NameDetail
dvk-started{ from, to, duration, delay }
dvk-finished{ value }

Slots

NameDescription
prefixCustom content before the number.
suffixCustom content after the number.

CSS Variables

NameMeaning
--dvk-count-to-colorRoot text color.
--dvk-count-to-font-familyNumber font family.
--dvk-count-to-font-sizeMain number font size.
--dvk-count-to-font-weightMain number font weight.
--dvk-count-to-gapGap between prefix, number, and suffix.
--dvk-count-to-affix-colorPrefix and suffix text color.
--dvk-count-to-affix-font-sizePrefix and suffix font size.
--dvk-count-to-decimal-colorDecimal text color.
--dvk-count-to-decimal-font-sizeDecimal font size.
--dvk-count-to-decimal-font-weightDecimal font weight.

Parts

PartDescription
rootInline wrapper.
prefixFallback prefix text.
mainNumber wrapper.
integerInteger text.
decimalDecimal text.
suffixFallback suffix text.