Components
- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Button Group
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Code Block
- Collapsible
- Combobox
- Command
- Context Menu
- Data Table
- Date Picker
- Dialog
- Direction
- Drawer
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input
- Input Group
- Input OTP
- Item
- Kbd
- Label
- Marker
- Message
- Message Scroller
- Native Select
- Pagination
- Popover
- Progress
- Questionnaire
- Radio Group
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toast
- Toggle
- Toggle Group
- Tooltip
- Trace
- Typography
AI Elements
Get Started
@shadcn/react
@shadcn/helpers
Utilities
"use client"
import * as React from "react""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 aria-label="Loading" value={progress} className="w-[60%]" />
}
Installation#
pnpm dlx shadcn@latest add progress
Install the following dependencies:
pnpm add react-aria-components
Copy and paste the following code into your project.
"use client"
import * as React from "react"
import { cn } from "cn"
import {
Label as LabelPrimitive,
ProgressBar as ProgressPrimitive,
type LabelProps,
type ProgressBarProps as ProgressPrimitiveProps,
} from "react-aria-components"
type ProgressContextValue = {
percentage?: number
isIndeterminate: boolean
valueText?: string
}
const ProgressContext = React.createContext<ProgressContextValue | null>(null)
function useProgress() {
const context = React.useContext(ProgressContext)
if (!context) {
throw new Error("useProgress must be used within a Progress.")
}
return context
}
function ProgressContent({
children,
percentage,
isIndeterminate,
valueText,
}: ProgressContextValue & {
children?: React.ReactNode
}) {
const context = React.useMemo(
() => ({ percentage, isIndeterminate, valueText }),
[percentage, isIndeterminate, valueText]
)
return (
<ProgressContext value={context}>
{children}
<ProgressTrack>
<ProgressIndicator />
</ProgressTrack>
</ProgressContext>
)
}
function Progress({
className,
children,
...props
}: Omit<ProgressPrimitiveProps, "children" | "className"> & {
children?: React.ReactNode
className?: string
}) {
return (
<ProgressPrimitive
data-slot="progress"
className={cn("flex flex-wrap gap-3", className)}
{...props}
>
{({ percentage, valueText, isIndeterminate }) => (
<ProgressContent
percentage={percentage}
valueText={valueText}
isIndeterminate={isIndeterminate}
>
{children}
</ProgressContent>
)}
</ProgressPrimitive>
)
}
function ProgressTrack({ className, ...props }: React.ComponentProps<"span">) {
return (
<span
className={cn(
"relative flex h-1 w-full items-center overflow-x-hidden rounded-full bg-muted",
className
)}
data-slot="progress-track"
{...props}
/>
)
}
function ProgressIndicator({
className,
style,
...props
}: React.ComponentProps<"span">) {
const { percentage, isIndeterminate } = useProgress()
return (
<span
data-slot="progress-indicator"
className={cn("h-full bg-primary transition-all", className)}
style={{
...style,
width: `${isIndeterminate ? 100 : (percentage ?? 0)}%`,
}}
{...props}
/>
)
}
function ProgressLabel({ className, ...props }: LabelProps) {
return (
<LabelPrimitive
className={cn("text-sm font-medium", className)}
data-slot="progress-label"
{...props}
/>
)
}
function ProgressValue({
className,
children,
...props
}: Omit<React.ComponentProps<"span">, "children"> & {
children?: (value: string) => React.ReactNode
}) {
const { valueText } = useProgress()
return (
<span
className={cn(
"ml-auto text-sm text-muted-foreground tabular-nums",
className
)}
data-slot="progress-value"
{...props}
>
{children && valueText != null ? children(valueText) : valueText}
</span>
)
}
export {
Progress,
ProgressTrack,
ProgressIndicator,
ProgressLabel,
ProgressValue,
}
Update the import paths to match your project setup.
Usage#
import { Progress } from "@/components/ui/progress"<Progress aria-label="Loading" 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
└── ProgressIndicatorLabel#
Use ProgressLabel and ProgressValue to add a label and value display.
Upload progress56%
import {
Progress,
ProgressLabel,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""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 aria-label="Loading" value={value} className="w-full" />
<Slider
aria-label="Progress"
value={value}
onChange={(value) => setValue(value as number)}
minValue={0}
maxValue={100}
step={1}
/>
</div>
)
}
RTL#
To enable RTL support in shadcn/ui, see the RTL configuration guide.
تقدم الرفع٥٦%
"use client"
import * as React from "react"// You will notice this example uses dir and data-lang attributes. // This is because this site is not RTL by default. // In your application, you won't need these.// See the RTL guide for more information.
"use client"
import * as React from "react"
import {
useTranslation,
type Translations,
} from "@/components/language-selector"
import {
Progress,
ProgressLabel,
ProgressValue,
} from "@/components/ui/progress"
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#
See the React Aria ProgressBar documentation.
Deploy your shadcn/ui app on Vercel
Trusted by OpenAI, Sonos, Adobe, and more.
Vercel provides tools and infrastructure to deploy apps and features at scale.
Deploy to Vercel