Skip to content

Commit c738d98

Browse files
authored
feat: progress bar with multiple segments (#1593)
1 parent 29f007b commit c738d98

File tree

3 files changed

+63
-4
lines changed

3 files changed

+63
-4
lines changed

docs/components/progress.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
title: Component - Progress
3+
order: 5
4+
description: Guide to Unfold's Progress component for displaying completion status through customizable single and multi-segment progress bars.
5+
---
6+
7+
# Progress component
8+
9+
The Progress component provides a visual representation of completion status or data distribution through customizable progress bars. It supports both single progress bars for displaying overall completion percentages and multi-segment progress bars that can be divided into multiple smaller sections with different widths and colors. This flexibility makes it ideal for showing complex data breakdowns, multi-step process completion, or comparative metrics within a unified visual element. The component integrates seamlessly with the Unfold design system and includes full dark mode support for consistent theming across different environments.
10+
11+
[![Progress](/static/docs/components/progress.webp)](/static/docs/components/progress.webp)
12+
13+
## Example function for passing arguments to progress bar
14+
15+
```python
16+
def progress_params():
17+
return {
18+
"title": "Progress bar title",
19+
"description": "Total 57.5%",
20+
"progress_class": "extra_css_class",
21+
"value": 57.5,
22+
}
23+
```
24+
25+
## Progress bar params with multiple segments
26+
27+
```python
28+
def multiple_progressbar_items():
29+
return {
30+
"title": "Progress bar title",
31+
"description": "Total 57.5%",
32+
"items": [
33+
{
34+
"title": "First part of progress bar",
35+
"value": 30.0,
36+
"progress-class": "override-color",
37+
},
38+
{
39+
"title": "Second part of progress bar",
40+
"value": 20.0,
41+
"progress-class": "use-another-color",
42+
},
43+
]
44+
}
45+
46+
```
47+
48+
```html
49+
{% load unfold %}
50+
51+
{% component "unfold/components/progress.html" with title=item.title description=item.description value=item.value %}
52+
{% endcomponent %}
53+
```

src/unfold/static/unfold/css/styles.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/unfold/templates/unfold/components/progress.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,15 @@ <h3 class="text-font-important-light dark:text-font-important-dark text-sm">
1515
</div>
1616
{% endif %}
1717

18-
{% if value %}
19-
<div class="bg-base-100 overflow-hidden rounded-default dark:bg-base-800">
20-
<div class="h-1.5 bg-primary-600 rounded-default z-10 dark:bg-primary-500 {{ progress_class }}" title="{{ value }}%" style="width: {{ value }}%"></div>
18+
{% if items or value %}
19+
<div class="bg-base-100 flex flex-row overflow-hidden rounded-default dark:bg-base-800">
20+
{% if items %}
21+
{% for item in items %}
22+
<div class="h-1.5 bg-primary-600 z-10 dark:bg-primary-500 last:rounded-r-default {{ item.progress_class }}" title="{% if item.title %}{{ item.title }}: {% endif %}{{ item.value }}%" style="width: {{ item.value }}%"></div>
23+
{% endfor %}
24+
{% elif value %}
25+
<div class="h-1.5 bg-primary-600 rounded-default z-10 last:rounded-r-default dark:bg-primary-500 {{ progress_class }}" title="{% if title %}{{ title }}: {% endif %}{{ value }}%" style="width: {{ value }}%"></div>
26+
{% endif %}
2127
</div>
2228
{% endif %}
2329
</div>

0 commit comments

Comments
 (0)