Meter

Style-agnostic meter / stacked progress component.

python 6 params

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

NameTypeDefaultDescription
segmentslist | NoneNoneList of segment dicts with value, color, label
totalint100Total value (default: 100)
labelstr''Overall meter label
show_legendboolTrueShow color legend below bar (default: True)
custom_classstr''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
FilePathNotes
moduledjust.components.components.meterSubclass it, or pass custom_class, to change how it renders.
cssdjust_components/components.cssDefines 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.