Progress
cubby-ui/progressFreeComponent
A progress component.
Live preview
live · rendered by the registry
Rendered by cubby-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://cubby-ui.dev/r/progress.jsonSource
1"use client";23import * as React from "react";4import { Progress as BaseProgress } from "@base-ui/react/progress";5import { cva, type VariantProps } from "class-variance-authority";67import { cn } from "@/lib/utils";89interface ProgressContextValue {10 size?: "sm" | "md" | "lg";11 animated?: boolean;12 value?: number | null;13 min?: number;14 max?: number;15 completed?: boolean;16}1718const ProgressContext = React.createContext<ProgressContextValue>({});1920const progressRootVariants = cva("w-full", {21 variants: {22 size: {23 sm: "space-y-1",24 md: "space-y-1.5",25 lg: "space-y-2",26 },27 },28 defaultVariants: {29 size: "md",30 },31});3233interface ProgressRootProps34 extends React.ComponentProps<typeof BaseProgress.Root>,35 VariantProps<typeof progressRootVariants> {36 animated?: boolean;37}3839function ProgressRoot({40 className,41 children,42 size,43 animated = false,44 value,45 min = 0,46 max = 100,47 ...props48}: ProgressRootProps) {49 const completed = value !== null && value !== undefined && value >= max;5051 const contextValue = React.useMemo(52 () => ({53 size: size ?? undefined,54 animated,55 value,56 min,57 max,58 completed,59 }),60 [size, animated, value, min, max, completed],61 );6263 return (64 <ProgressContext.Provider value={contextValue}>65 <BaseProgress.Root66 value={value}67 min={min}68 max={max}69 data-slot="progress"70 className={cn(progressRootVariants({ size }), className)}71 {...props}72 >73 {children}74 </BaseProgress.Root>75 </ProgressContext.Provider>76 );77}7879const progressTrackVariants = cva(80 "relative w-full overflow-hidden rounded-full bg-primary/15 shadow-[inset_0_1px_2px_0_oklch(0.18_0_0_/_0.06)]",81 {82 variants: {83 size: {84 sm: "h-2",85 md: "h-2.5",86 lg: "h-3.5",87 },88 },89 defaultVariants: {90 size: "md",91 },92 },93);9495interface ProgressTrackProps96 extends React.ComponentProps<typeof BaseProgress.Track> {97 striped?: boolean;98}99100function ProgressTrack({101 className,102 children,103 striped,104 ...props105}: ProgressTrackProps) {106 const { size } = React.useContext(ProgressContext);107108 return (109 <BaseProgress.Track110 data-slot="progress-track"111 className={cn(112 progressTrackVariants({ size }),113 striped &&114// … truncated
What it pulls in
npm packages
Files it writes
More from cubby-ui
All 79 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | cubby-ui | Components | Free | 2 deps | |
| Alertalert | cubby-ui | Components | Free | 1 dep | |
| Alert-dialogalert-dialog | cubby-ui | Components | Free | 2 deps | |
| Aspect-ratioaspect-ratio | cubby-ui | Components | Free | no deps | |
| Autocompleteautocomplete | cubby-ui | Components | Free | 2 deps | |
| Avataravatar | cubby-ui | Components | Free | 1 dep | |
| Badgebadge | cubby-ui | Components | Free | 1 dep | |
| Base Drawerbase-drawer | cubby-ui | Components | Free | 2 deps |
