"use client"
import * as React from "react"
import { Progress } from "@/components/ui/progress"
export function ProgressDemo() {
const [progress, setProgress] = React.useState(13)
React.useEffect(() => {
const timer = setTimeout(() => setProgress(66), 500)
return () => clearTimeout(timer)
}, [])
return <Progress value={progress} className="w-[60%]" />
}Installation
npx shadcn@latest add @fulldev/progress
Usage
import { Progress } from "@/components/ui/progress"
<Progress value={33} />
Composition
With label and value
Use ProgressLabel and ProgressValue to add a label and value display.
import {
Progress,
ProgressLabel,
ProgressValue,
} from "@/components/ui/progress"
;<Progress value={56} className="w-full max-w-sm">
<ProgressLabel>Upload progress</ProgressLabel>
<ProgressValue />
</Progress>
Progress
├── ProgressLabel
├── ProgressValue
└── ProgressTrack
└── ProgressIndicator
Label
Use ProgressLabel and ProgressValue to add a label and value display.
import {
Progress,
ProgressLabel,
ProgressValue,
} from "@/components/ui/progress"
export function ProgressWithLabel() {
return (
<Progress value={56} className="w-full max-w-sm">
<ProgressLabel>Upload progress</ProgressLabel>
<ProgressValue />
</Progress>
)
}Controlled
A progress bar that can be controlled by a slider.
"use client"
import * as React from "react"
import { Progress } from "@/components/ui/progress"
import { Slider } from "@/components/ui/slider"
export function ProgressControlled() {
const [value, setValue] = React.useState(50)
return (
<div className="flex w-full max-w-sm flex-col gap-4">
<Progress value={value} className="w-full" />
<Slider
value={value}
onValueChange={(value) => setValue(value as number)}
min={0}
max={100}
step={1}
/>
</div>
)
}RTL
To enable RTL support in shadcn/ui, see the RTL configuration guide.
"use client"
import * as React from "react"
import {
Progress,
ProgressLabel,
ProgressValue,
} from "@/components/ui/progress"
import {
useTranslation,
type Translations,
} from "@/components/language-selector"
const translations: Translations = {
en: {
dir: "ltr",
values: {
label: "Upload progress",
},
},
ar: {
dir: "rtl",
values: {
label: "تقدم الرفع",
},
},
he: {
dir: "rtl",
values: {
label: "התקדמות העלאה",
},
},
}
function toArabicNumerals(num: number): string {
const arabicNumerals = ["٠", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩"]
return num
.toString()
.split("")
.map((digit) => arabicNumerals[parseInt(digit, 10)])
.join("")
}
export function ProgressRtl() {
const { dir, t, language } = useTranslation(translations, "ar")
const formatNumber = (num: number): string => {
if (language === "ar") {
return toArabicNumerals(num)
}
return num.toString()
}
return (
<Progress value={56} className="w-full max-w-sm" dir={dir}>
<ProgressLabel>{t.label}</ProgressLabel>
<ProgressValue>
{(value) => (
<span className="ms-auto">
{formatNumber(parseFloat(value ?? "0"))}%
</span>
)}
</ProgressValue>
</Progress>
)
}API Reference
Source: react/src/components/ui/progress.tsx
See the Base UI Progress documentation.