Data & Media
@hacline/ui/progressProgress
Display current task progress or an indeterminate waiting state.
Usage
Advance by 25% per click and reset once complete. Pass value={null} when total progress cannot be determined yet.
Generating report
"use client";
import { useState } from "react";
import { Button } from "@/components/ui/hacline/components/button";
import {
Progress,
ProgressIndicator,
ProgressLabel,
ProgressTrack,
ProgressValue,
} from "@/components/ui/hacline/components/progress";
const STEP = 25;
const TOTAL = 100;
export const Example = () => {
const [value, setValue] = useState(25);
return (
<div className="grid w-full max-w-xs justify-items-start gap-3">
<Progress value={value}>
<ProgressLabel>Generating report</ProgressLabel>
<ProgressValue />
<ProgressTrack>
<ProgressIndicator />
</ProgressTrack>
</Progress>
<Button
onClick={() => setValue(value === TOTAL ? 0 : value + STEP)}
size="sm"
variant="outline"
>
{value === TOTAL ? "Reset" : "Advance step"}
</Button>
</div>
);
};Waiting for Total Size
Starts with value={null} and switches to a determinate percentage once totals arrive.
Loading import job
"use client";
import { useState } from "react";
import { Button } from "@/components/ui/hacline/components/button";
import {
Progress,
ProgressIndicator,
ProgressLabel,
ProgressTrack,
ProgressValue,
} from "@/components/ui/hacline/components/progress";
export const Example = () => {
const [measured, setMeasured] = useState(false);
return (
<div className="grid w-full max-w-xs justify-items-start gap-2">
<Progress value={measured ? 35 : null}>
<ProgressLabel>Loading import job</ProgressLabel>
<ProgressValue>{measured ? "35%" : "Counting items..."}</ProgressValue>
<ProgressTrack>
<ProgressIndicator />
</ProgressTrack>
</Progress>
<Button
onClick={() => setMeasured(!measured)}
size="sm"
variant="outline"
>
{measured ? "Simulate unknown total" : "Simulate known total"}
</Button>
</div>
);
};Parts
| Part | Description | Extended Props |
|---|---|---|
ProgressIndicator | The filled part of the track, as wide as the value. | — |
ProgressLabel | Names the progress bar. | — |
ProgressTrack | The rail the indicator fills. | size |
ProgressValue | The formatted value, like "40%". Children replace it. | — |
Props
Prop
Type