Animated Number
Animated counting number display.
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
| Name | Type | Default |
|---|---|---|
| value | float | 0 |
| prefix | str | '' |
| suffix | str | '' |
| duration | int | 800 |
| decimals | int | 0 |
| separator | str | ',' |
| custom_class | str | '' |
| **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
| File | Path | Notes |
|---|---|---|
| module | djust.components.components.animated_number | Subclass it, or pass custom_class, to change how it renders. |
| css | djust_components/components.css | Defines 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. |