Progress
NewCustomize
All
Thickness8px
auto
Installation
npx shadcn@latest add https://uibrik.com/r/progress.jsonInstall the packages
npm install motionAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/progress/progress.tsx"use client"; import { useEffect, useId, useLayoutEffect, useRef, useState, type ReactNode } from "react"; import { AnimatePresence, MotionConfig, motion, useSpring, useTransform } from "motion/react"; import { cn } from "@/lib/utils"; // Progress in four shapes that share one look: a bar, a ring, a segmented bar // for a breakdown (storage, budget, quota) and a list of steps. Values ease to // where they're going on a spring, so updates that arrive faster than the // animation never make it stutter or step, and the numbers roll rather than // flicker. Reaching the end turns the bar or ring green and draws a check. // In the segmented bar, pointing at a legend row lights up its segment and // dims the rest; in the steps, a finished step draws its check while the rail // fills down to the next one, and the running step shows its own progress. // // Everything moves with transforms only, and a value of null shows an // indeterminate bar. export type ProgressSegment = { label: string; value: number; /** Any CSS colour. Defaults run through a quiet palette. */ color?: string; };
Adds the files to
components/uibrik/progress and installs motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/progress.Usage
import { Progress } from "@/components/uibrik/progress/progress";<Progress showValue thickness={8} orientation="auto" value={null} label="Exporting launch-film.mp4" detail="Preparing export…" // variant="bar" // max={0} // segments={[{ label: …, value: … }]} // format={(n) => {}} // freeLabel="…" // steps={[{ label: … }]} // current={0} // stepProgress={…} // size={0}/>Props
Progress- showValue
- Type boolean
- true
- The percentage or total next to the progress.
- thickness
- Type number
- 8
- Height of the bars and width of the ring's stroke.
- orientation
- Type "auto" | "vertical" | "horizontal"
- "auto"
- Steps: a row across when there's room, else a list down the side.
- variant
- Type "bar" | "ring" | "segments" | "steps"
- "bar"
- Shape of the progress.
- value / max
- Type number | null / number
- — / 100
- Bar and ring. A null value makes the bar indeterminate.
- label / detail
- Type string / ReactNode
- –
- A name above, and a quieter line below (e.g. bytes sent and time left).
- segments
- Type { label; value; color? }[]
- –
- Segments: the breakdown, in order. Whatever's left of max shows as free.
- format / freeLabel
- Type (n) => string / string
- –
- Segments: how values read in the legend, and what to call the rest.
- steps / current / stepProgress
- Type { label; detail? }[] / number / 0–1
- –
- Steps: the list, the index of the running one (steps.length when all done), and how far it is.
- size
- Type number
- 120
- Ring: diameter in px.
- className
- Type string
- –
- Classes for the wrapper.