Adjustable
Update a named progress bar and its visible percentage together. The buttons change the value that both the fill and aria-valuenow report.
"use client"
import * as React from "react"
import { Button } from "@/components/ui/button"
import { Progress } from "@/components/ui/progress"
export function ProgressAdjustable() {
const [value, setValue] = React.useState(45)
return (
<div className="flex w-full max-w-sm flex-col gap-8">
<div className="flex w-full flex-col gap-4">
<Progress value={value} aria-label="Upload progress" />
<div className="flex items-center justify-between">
<span className="text-paragraph-sm text-sub-600">{value}%</span>
<div className="flex gap-2">
<Button
size="xs"
intent="neutral"
emphasis="stroke"
onClick={() => setValue((current) => Math.max(0, current - 15))}
>
-15
</Button>
<Button
size="xs"
intent="neutral"
emphasis="stroke"
onClick={() => setValue((current) => Math.min(100, current + 15))}
>
+15
</Button>
</div>
</div>
</div>
</div>
)
}