Progress Indicator
Progress indicators show the status of a process in real time.
Progress indicators show the real-time status of a process. Features include determinate and indeterminate modes, circular indicators, and expressive wavy linear bars.
Introduction
The MD3 Expressive Progress Indicator provides visual feedback for tasks that take more than a few seconds. It supports both Linear and Circular formats, and offers a unique Wavy design style that adds a layer of sophisticated motion to the standard progress bar. It handles both determinate (known progress) and indeterminate (unknown duration) states gracefully.
Anatomy
- Track: The background line or circle representing the total progress.
- Indicator: The active part of the bar or circle representing completed progress.
- Wavy Element (Optional): A dynamic SVG path that adds a wave effect to the indicator.
Variants
Linear Progress
Horizontal bars that are ideal for placement at the top of a surface or container.
Circular Progress
Circular indicators that are best for smaller spaces or when a more centered focus is required.
Features
Determinate vs Indeterminate
- Determinate: Use when the percentage of completion is known.
- Indeterminate: Use when the duration of the task is unknown.
Wavy Motion
The shape="wavy" prop transforms the flat progress bar into an animated wave. This expressive style is perfect for high-end interfaces that want to stand out.
Use Cases & Integration
Practical examples of progress indicators integrated into action controls like buttons during async operations.
Usage
Basic Linear Progress
import { ProgressIndicator } from "@bug-on/m3-expressive";
<ProgressIndicator value={60} aria-label="Loading profile status" />
Indeterminate Circular Progress
<ProgressIndicator variant="circular" aria-label="Loading resources" />
Expressive Wavy Progress
<ProgressIndicator
shape="wavy"
value={45}
amplitude={6}
wavelength={30}
aria-label="Processing video export"
/>
Best Practices
Do
- Use Determinate progress whenever the duration can be calculated.
- Provide an
aria-labelthat describes what is being loaded. - Use Linear progress for long processes like file uploads or page loads.
- Use Circular progress for smaller, contextual loading (e.g., inside a card).
Don't
- Don't use a progress indicator if the task takes less than 1 second.
- Don't switch between determinate and indeterminate states frequently; it can be confusing.
- Avoid using too many wavy indicators on a single page, as the motion can be distracting.
Accessibility
- Roles: Automatically applies
role="progressbar". - States: Manages
aria-valuenow,aria-valuemin, andaria-valuemaxfor determinate states. - Indeterminate: Removes
aria-valuenowto signal unknown progress to screen readers.
API Reference
ProgressIndicator
Component ProgressIndicator nhận các thuộc tính chung cùng các cấu hình đặc trưng tùy theo kiểu hiển thị linear hoặc circular.
Shared Props (Thuộc tính dùng chung)
| Prop | Type | Default | Description |
|---|---|---|---|
aria-label | string | — | Bắt buộc. Nhãn mô tả tiến trình phục vụ cho khả năng tiếp cận (Accessibility). |
value | number | — | Phần trăm tiến trình hoàn thành (từ 0 đến 100). Nếu truyền, component hiển thị ở trạng thái Determinate. Nếu bỏ qua, component tự động hoạt động ở trạng thái Indeterminate. |
trackHeight | number | — | Độ dày của thanh tiến trình (đối với Linear là chiều cao thanh, đối với Circular là độ dày đường viền vẽ vòng tròn, đơn vị px). |
color | string | "currentColor" | Màu sắc của phần tiến trình đang chạy. |
trackColor | string | — | Màu sắc của đường ray nền (phần chưa hoàn thành). |
className | string | — | Lớp CSS bổ sung cho container bên ngoài. |
Linear-specific Props (Chỉ áp dụng khi variant="linear")
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "linear" | "linear" | Xác định kiểu hiển thị dạng thanh ngang. |
shape | "flat" | "wavy" | "flat" | Kiểu dáng thiết kế của thanh chỉ báo tiến trình đang chạy. |
trackShape | "flat" | "wavy" | "flat" | Kiểu dáng thiết kế của đường ray nền. |
amplitude | number | 4 | Biên độ (độ cao đỉnh sóng) khi dùng kiểu wavy. |
wavelength | number | 20 | Chiều dài bước sóng của một chu kỳ sóng ở trạng thái Determinate Wavy. |
indeterminateWavelength | number | — | Chiều dài bước sóng dành riêng cho chế độ Indeterminate Wavy. |
gapSize | number | — | Khoảng trống phân tách giữa thanh chạy và đường ray nền. Đặt 0 để tạo làn sóng liền mạch. |
waveSpeed | number | 1 | Hệ số điều chỉnh tốc độ chuyển động cuộn của sóng. |
crawlerSpeed | number | 1 | Hệ số điều chỉnh tốc độ di chuyển của thanh trượt trong trạng thái Indeterminate. |
determinateAnimation | "md3" | "continuous" | "md3" | Cơ chế làm giảm độ cao sóng khi tiến trình gần chạm biên (dưới hoặc bằng 10% hoặc lớn hơn hoặc bằng 90%). "md3" làm phẳng sóng dần về 0; "continuous" giữ nguyên biên độ sóng suốt chiều dài. |
indeterminateAnimation | "md3" | "continuous" | "md3" | Kiểu chuyển động khi chạy vô hạn. "md3" sử dụng hiệu ứng 2 thanh trượt co giãn vật lý; "continuous" sử dụng dải chạy lặp liên tục mượt mà. |
showStopIndicator | boolean | "auto" | — | Hiển thị chấm tròn kết thúc ở góc cuối đường ray. "auto" sẽ chỉ hiển thị và mờ dần (fade-in) khi tiến độ đạt 100%. |
Circular-specific Props (Chỉ áp dụng khi variant="circular")
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "circular" | — | Xác định kiểu hiển thị dạng vòng tròn xoay. |
size | number | 48 | Đường kính hiển thị của vòng tròn (px). |
shape | "flat" | "wavy" | "flat" | Kiểu nét vẽ vòng tròn (nét trơn phẳng hoặc nét lượn sóng). |
trackShape | "flat" | "wavy" | "flat" | Kiểu nét vẽ của đường ray nền khi shape="wavy" ở Determinate mode (nét trơn phẳng hoặc nét lượn sóng). |
amplitude | number | — | Biên độ dao động sóng quanh viền tròn. |
wavelength | number | — | Tổng số chu kỳ sóng phân bố đều trên chu vi vòng tròn. |
gapSize | number | — | Khoảng cách phân cách giữa hai đầu của cung tiến trình. |
waveSpeed | number | 1 | Hệ số điều chỉnh tốc độ chuyển động cuộn của sóng. |
determinateAnimation | "md3" | "continuous" | "md3" | Cơ chế phẳng sóng ở các mốc biên (dưới hoặc bằng 10% hoặc lớn hơn hoặc bằng 95%). "md3" làm phẳng nét sóng về đường tròn thẳng ở 0% và 100%; "continuous" giữ nét sóng cuộn liên tục ở mọi mức tiến độ. |
crawlerSpeed | number | — | Tốc độ quay của cung trượt trong trạng thái Indeterminate. |
showTrack | boolean | "auto" | "auto" | Hiển thị đường ray nền phía sau trong trạng thái Indeterminate. "auto" tự động ẩn với flat và hiện với wavy. |
minProgress | number | 0.1 | Tỷ lệ chiều dài cung tối thiểu (từ 0 đến 1) khi co giãn ở trạng thái Indeterminate. |
maxProgress | number | 0.8 | Tỷ lệ chiều dài cung tối đa (từ 0 đến 1) khi co giãn ở trạng thái Indeterminate. |
amplitudeRange | [number, number] | [0, effectiveAmplitude] | Khoảng biến thiên biên độ sóng [min, max] ở trạng thái Indeterminate. Giúp sóng phẳng đi khi cung thu ngắn và đạt biên độ tối đa khi cung giãn dài. |