Progress
Style-agnostic progress bar component using CSS custom properties.
Preview
Progress 25%
Progress 50%
Progress 75%
Progress 100%
Loading...
Usage
views.py
python
from djust import LiveView
class MyView(LiveView):
template_name = "my_template.html"
def mount(self, request, **kwargs):
self.value = 25my_template.html
django
{% load theme_components %}
{% theme_progress value=value max=100 label='Progress 25%' %}Props
| Name | Type | Required | Default |
|---|---|---|---|
| value | Optional[int] | — | |
| max | int | 100 | |
| label | str | — | |
| css_prefix | str | — | |
| attrs | dict | — | |
| slot_label | str | — |
Accessibility
| Requirement | Element | Attribute | Value |
|---|---|---|---|
| Progress must have role=progressbar | div | role | progressbar |
Slots
slot_label
Source & styles
| File | Path | Notes |
|---|---|---|
| template | djust_theming/components/progress.html | Copy it to the same path in your project, or per theme under djust_theming/themes/<theme>/components/. |
| css | djust_theming/components.css | Defines 5 of this component's classes at line 904, 910, 916, 925, 932. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |
| css | djust_components/components.css | Defines 3 of this component's classes at line 129, 131, 136. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |
CSS variables
--foreground --muted --primary
Template source — progress.html
django
<div class="{{ css_prefix }}progress-wrapper {% if attrs.class %}{{ attrs.class }}{% endif %}"
{% if attrs.id %}id="{{ attrs.id }}"{% endif %}>
{% if slot_label %}
{{ slot_label|safe }}
{% elif label %}
<div class="{{ css_prefix }}progress-label">{{ label }}</div>
{% endif %}
<div class="{{ css_prefix }}progress {% if is_indeterminate %}{{ css_prefix }}progress-indeterminate{% endif %}"
role="progressbar"
aria-valuemin="0"
aria-valuemax="{{ max }}"
{% if not is_indeterminate %}aria-valuenow="{{ value }}"{% endif %}
{% if label %}aria-label="{{ label }}"{% endif %}>
{% if not is_indeterminate %}
<div class="{{ css_prefix }}progress-bar" style="width: {{ percentage }}%"></div>
{% endif %}
</div>
</div>