MCPcopy Create free account
hub / github.com/adobe/react-spectrum / ProgressBar

Function ProgressBar

starters/hooks/src/ProgressBar.tsx:7–34  ·  view source on GitHub ↗
(props: AriaProgressBarProps)

Source from the content-addressed store, hash-verified

5import './Form.css';
6
7export function ProgressBar(props: AriaProgressBarProps) {
8 let {label, value = 0, minValue = 0, maxValue = 100, isIndeterminate} = props;
9 /*- begin highlight -*/
10 let {progressBarProps, labelProps} = useProgressBar(props);
11 /*- end highlight -*/
12
13 // Calculate the width of the progress fill as a percentage.
14 let percentage = ((value - minValue) / (maxValue - minValue)) * 100;
15
16 return (
17 <div {...progressBarProps} className="react-aria-ProgressBar">
18 <label className="react-aria-Label" {...labelProps}>
19 {label}
20 </label>
21 <span className="value">{progressBarProps['aria-valuetext']}</span>
22 <div className="track inset">
23 <div
24 className="fill"
25 style={
26 {'--percent': (isIndeterminate ? 100 : percentage) + '%'} as CSSProperties & {
27 '--percent': string;
28 }
29 }
30 />
31 </div>
32 </div>
33 );
34}

Callers

nothing calls this directly

Calls 1

useProgressBarFunction · 0.90

Tested by

no test coverage detected