Animated Number

Animated counting number display.

python 8 params

Preview

1,234
Arguments
animated_number(value=1234, duration=1000)

Usage

views.py
python
from djust import LiveView
from djust.components import AnimatedNumber


class MyView(LiveView):
    template_name = "my_template.html"

    def mount(self, request, **kwargs):
        self.component = AnimatedNumber(value=1234, duration=1000)
my_template.html
django
{{ component }}

Needs a client hook djust does not ship: dj-hook="AnimatedNumber". The markup renders, but the interaction described above is yours to add — register window.djust.hooks.AnimatedNumber = { mounted() { … } } before client.js loads (see the hooks guide).

Parameters

NameTypeDefault
valuefloat0
prefixstr''
suffixstr''
durationint800
decimalsint0
separatorstr','
custom_classstr''
**kwargs— passed to `Component.__init__`: `name=` identifies the instance in the events it sends, `id=` sets `component.id`, and any other keyword is kept as state
Source & styles
FilePathNotes
moduledjust.components.components.animated_numberSubclass it, or pass custom_class, to change how it renders.
cssdjust_components/components.cssDefines 2 of this component's classes at line 2327, 2329. Override those rules, or the custom properties they read, in a stylesheet loaded after it.