Progress
blok/progressFreeComponent
Displays an indicator showing the completion progress of a task, typically displayed as a progress bar.
Install it
npx shadcn@latest add https://blok.sitecore.com/r/progress.jsonSource
1"use client";23import { Progress as ProgressPrimitive } from "radix-ui";4import { useEffect } from "react";5import type * as React from "react";67import { cn } from "@/lib/utils";89const PROGRESS_STYLE_ID = "progress-indeterminate-styles";1011// bar is 50% width, slides from left -40% to 100%12const indeterminateKeyframes = `@keyframes progressIndeterminate{0%{left:-40%}100%{left:100%}}`;1314function useProgressStyles(needed: boolean | undefined) {15 useEffect(() => {16 if (!needed || document.getElementById(PROGRESS_STYLE_ID)) return;17 const style = document.createElement("style");18 style.id = PROGRESS_STYLE_ID;19 style.textContent = indeterminateKeyframes;20 document.head.appendChild(style);21 }, [needed]);22}2324interface ProgressProps25 extends React.ComponentProps<typeof ProgressPrimitive.Root> {26 variant?: "default" | "indeterminate";27 isIndeterminate?: boolean;28}2930function Progress({31 className,32 value,33 variant,34 isIndeterminate,35 ...props36}: ProgressProps) {37 const indeterminate = variant === "indeterminate" || isIndeterminate;38 useProgressStyles(indeterminate);3940 return (41 <ProgressPrimitive.Root42 data-slot="progress"43 data-indeterminate={indeterminate ? "" : undefined}44 aria-label={indeterminate ? "Progress" : `Progress: ${value ?? 0}%`}45 className={cn(46 "relative h-2 w-full overflow-hidden rounded-full bg-neutral-bg",47 className,48 )}49 {...props}50 >51 <ProgressPrimitive.Indicator52 data-slot="progress-indicator"53 className={cn(54 "h-full rounded-full transition-all",55 indeterminate56 ? "absolute min-w-[50%] w-[50%] bg-primary"57 : "flex-1 w-full bg-primary",58 )}59 style={60 indeterminate61 ? { animation: "progressIndeterminate 1.5s ease infinite" }62 : { transform: `translateX(-${100 - (value ?? 0)}%)` }63 }64 />65 </ProgressPrimitive.Root>66 );67}6869export { Progress, type ProgressProps };
What it pulls in
npm packages
Other registry items
Files it writes
More from blok
All 72 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | blok | Components | Free | 2 deps · 2 files | |
| Action baraction-bar | blok | Components | Free | 1 dep · 2 files | |
| Alertalert | blok | Components | Free | 2 deps · 2 files | |
| Alert dialogalert-dialog | blok | Components | Free | 2 deps | |
| Aspect ratioaspect-ratio | blok | Components | Free | 1 dep | |
| Avataravatar | blok | Components | Free | 1 dep | |
| Badgebadge | blok | Components | Free | 2 deps | |
| All componentsblok-components | blok | Components | Free | no deps |
