Skip to content

Counter ​

A number that counts to its value, with a label.

tsx
import { Background, Composition, Counter, Track } from "@cutcraft/kit";

// Counter: a number that counts to its value, then holds, with a label under it.
export default function Video() {
  return (
    <Composition fps={30} width={1920} height={1080}>
      <Track id="back" layout="free">
        <Background id="bg" start={0} duration={3} variant="gradient" />
      </Track>
      <Track id="over" layout="free">
        <Counter id="cups" start={0.2} duration={2.8} to={12400} suffix="+" label="cups poured this year" size={180} />
      </Track>
    </Composition>
  );
}

Props ​

Besides the timing props (start, anchor, at, offset, duration):

paramtypedefaultdescription
idstringThe component's id; each of its parts' ids starts with it.
fromnumber0The number it counts from.
tonumberThe number it counts to and then holds.
decimalsinteger (0..4)0How many digits show after the decimal point.
prefixstring""Text before the number, such as $.
suffixstring""Text after the number, such as %.
labelstringA line under the number, in the body face and the muted colour. Left out: the number alone.
xnumber0The number's centre, in pixels from the frame's centre.
ynumber0The number's centre, in pixels below the frame's centre.
sizenumber (> 0)140The number's letter height in pixels; the label is about a fifth of it.
countFornumber (> 0)1.5Seconds the count takes; it then holds.

All components

MIT licensed.