Meter
Style-agnostic meter / stacked progress component.
Preview
Storage
Used70
Arguments
meter(segments=[{'value': 70, 'label': 'Used'}], total=100, label='Storage')Memory
Used30
Arguments
meter(segments=[{'value': 30, 'label': 'Used'}], total=100, label='Memory')Usage
views.py
python
from djust import LiveView
from djust.components import Meter
class MyView(LiveView):
template_name = "my_template.html"
def mount(self, request, **kwargs):
self.component = Meter(segments=[{'value': 70, 'label': 'Used'}], total=100, label='Storage')my_template.html
django
{{ component }}Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| segments | list | None | None | List of segment dicts with value, color, label |
| total | int | 100 | Total value (default: 100) |
| label | str | '' | Overall meter label |
| show_legend | bool | True | Show color legend below bar (default: True) |
| custom_class | str | '' | Additional CSS classes |
| **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.meter | Subclass it, or pass custom_class, to change how it renders. |
| css | djust_components/components.css | Defines 9 of this component's classes at line 1897, 1898, 1899, 1904, 1905, 1906, 1907, 1908, 1909. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |