MCPcopy Create free account
hub / github.com/DioxusLabs/dioxus-components / Progress

Function Progress

primitives/src/progress.rs:54–83  ·  view source on GitHub ↗
(props: ProgressProps)

Source from the content-addressed store, hash-verified

52/// - `--progress-value`: A value between 0 and 100 representing the current progress percentage.
53#[component]
54pub fn Progress(props: ProgressProps) -> Element {
55 // Calculate percentage for styling and "data-state"
56 let percentage = use_memo(move || {
57 props.value.cloned().map(|v| {
58 let max = (props.max)();
59 (v / max) * 100.0
60 })
61 });
62
63 let state = use_memo(move || match percentage() {
64 Some(_) => "loading",
65 None => "indeterminate",
66 });
67
68 rsx! {
69 div {
70 role: "progressbar",
71 "aria-valuemin": 0,
72 "aria-valuemax": props.max,
73 "aria-valuenow": props.value.cloned(),
74 "data-state": state,
75 "data-value": props.value.cloned().map(|v| v.to_string()),
76 "data-max": props.max,
77 style: percentage().map(|p| format!("--progress-value: {p}%")),
78 ..props.attributes,
79
80 {props.children}
81 }
82 }
83}
84
85/// The props for the [`ProgressIndicator`] component.
86#[derive(Props, Clone, PartialEq)]

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected