Indeterminate progress
Five indeterminate indicators for unknown durations: a bar sweep, dual bars, a pulsing track, marching dashes and a comet. Each is sized and token-driven.
Installation
The styled layer is free and installs like any other ai2 component.
Run the following command
npx shadcn@latest add @ai2/progress-indeterminateDependencies, the @ai2/tokens theme and the component file are installed together.
Install dependencies
npm install motionCopy the source
components/ui/progress-indeterminate.tsx"use client"
import type * as React from "react"
import { motion, useReducedMotion } from "motion/react"
import { cn } from "@/lib/utils"
/* Indeterminate progress family: loading of unknown duration. It takes NO value, so there is no aria-valuenow. Colour comes ONLY from tokens. framer-motion drives the continuous sweep, march and trail; under reduced-motion the motion stops and a static partial bar is shown. */
export type StyledSize = "sm" | "md" | "lg" | "xl"
const track: Record<StyledSize, string> = {
sm: "h-1",
md: "h-1.5",
lg: "h-2.5",
xl: "h-3.5",
}
const trackBase = "relative w-56 max-w-full overflow-hidden rounded-full bg-secondary"
type Props = React.ComponentProps<"div"> & { size?: StyledSize; label?: string }
/* BarSweep: tek token bar iz boyunca sola-saga gidip gelir. */
export function BarSweepProgress({ className, size = "md", label = "Loading", ...props }: Props) {
const reduce = useReducedMotion()
return (
<div
data-slot="styled-progress"
role="progressbar"
aria-label={label}
aria-valuemin={0}
aria-valuemax={100}
className={cn(trackBase, track[size], className)}
{...props}
>
{reduce ? (
<span className="absolute inset-y-0 left-0 w-2/5 rounded-full bg-primary" />
) : (
<motion.span
className="absolute inset-y-0 w-2/5 rounded-full bg-primary"
animate={{ left: ["0%", "60%"] }}
transition={{ duration: 1.1, ease: "easeInOut", repeat: Infinity, repeatType: "reverse" }}
/>
)}
</div>
)
}
/* DualBar: two token bars sweep offset from each other with different widths and delays. */
export function DualBarProgress({ className, size = "md", label = "Loading", ...props }: Props) {
const reduce = useReducedMotion()
return (
<div
data-slot="styled-progress"
role="progressbar"
aria-label={label}
aria-valuemin={0}
aria-valuemax={100}
className={cn(trackBase, track[size], className)}
{...props}
>
{reduce ? (
<span className="absolute inset-y-0 left-0 w-1/2 rounded-full bg-primary" />
) : (
<>
<motion.span
className="absolute inset-y-0 w-2/5 rounded-full bg-primary"
animate={{ left: ["-40%", "100%"] }}
transition={{ duration: 1.4, ease: "easeInOut", repeat: Infinity }}
/>
<motion.span
className="absolute inset-y-0 w-1/4 rounded-full bg-[color-mix(in_oklab,var(--color-primary)_55%,transparent)]"
animate={{ left: ["-25%", "100%"] }}
transition={{ duration: 1.4, ease: "easeInOut", repeat: Infinity, delay: 0.55 }}
/>
</>
)}
</div>
)
}
/* PulseTrack: tum iz boyunca token dolgu opaklik nabzi atar. */
export function PulseTrackProgress({ className, size = "md", label = "Loading", ...props }: Props) {
const reduce = useReducedMotion()
return (
<div
data-slot="styled-progress"
role="progressbar"
aria-label={label}
aria-valuemin={0}
aria-valuemax={100}
className={cn(trackBase, track[size], className)}
{...props}
>
{reduce ? (
<span className="absolute inset-0 rounded-full bg-[color-mix(in_oklab,var(--color-primary)_60%,transparent)]" />
) : (
<motion.span
className="absolute inset-0 rounded-full bg-primary"
animate={{ opacity: [0.35, 1, 0.35] }}
transition={{ duration: 1.3, ease: "easeInOut", repeat: Infinity }}
/>
)}
</div>
)
}
/* March: iz boyunca yuruyen token cizgiler (marching dashes). */
export function MarchProgress({ className, size = "md", label = "Loading", ...props }: Props) {
const reduce = useReducedMotion()
return (
<div
data-slot="styled-progress"
role="progressbar"
aria-label={label}
aria-valuemin={0}
aria-valuemax={100}
className={cn(trackBase, track[size], className)}
{...props}
>
<motion.span
className="absolute inset-0 [background-image:repeating-linear-gradient(90deg,var(--color-primary)_0,var(--color-primary)_6px,transparent_6px,transparent_12px)] [background-size:12px_100%]"
animate={reduce ? undefined : { backgroundPositionX: ["0px", "12px"] }}
transition={reduce ? undefined : { duration: 0.6, ease: "linear", repeat: Infinity }}
/>
</div>
)
}
/* Comet: token bir nokta + arkasinda solan kuyruk iz boyunca kosar. */
export function CometProgress({ className, size = "md", label = "Loading", ...props }: Props) {
const reduce = useReducedMotion()
return (
<div
data-slot="styled-progress"
role="progressbar"
aria-label={label}
aria-valuemin={0}
aria-valuemax={100}
className={cn(trackBase, track[size], className)}
{...props}
>
{reduce ? (
<span className="absolute inset-y-0 left-0 w-1/3 rounded-full [background-image:linear-gradient(90deg,transparent,var(--color-primary))]" />
) : (
<motion.span
className="absolute inset-y-0 w-1/3 rounded-full [background-image:linear-gradient(90deg,transparent,color-mix(in_oklab,var(--color-primary)_60%,transparent),var(--color-primary))]"
animate={{ left: ["-33%", "100%"] }}
transition={{ duration: 1.5, ease: "easeInOut", repeat: Infinity }}
/>
)}
</div>
)
}Manual installs skip the @ai2/tokens theme, so add the token CSS from the theming guide or the tone colors will be missing.
Variations
5 takes on the same idea. Each is its own export, and every one accepts a size prop (sm, md, lg, xl) aligned to the base Button scale.
Bar sweep
A token bar sweeps back and forth.
import { BarSweepProgress } from "@/components/ui/progress-indeterminate"
<BarSweepProgress />Dual bar
Two bars sweep offset.
import { DualBarProgress } from "@/components/ui/progress-indeterminate"
<DualBarProgress />Pulse track
The whole track pulses opacity.
import { PulseTrackProgress } from "@/components/ui/progress-indeterminate"
<PulseTrackProgress />March
Marching dashes move along the track.
import { MarchProgress } from "@/components/ui/progress-indeterminate"
<MarchProgress />Comet
A token dot with a trail runs the track.
import { CometProgress } from "@/components/ui/progress-indeterminate"
<CometProgress />ai2 Indeterminate progress: 5 styled variations on the token system
The ai2 Indeterminate progress are a set of 5 decorative button variations from the styled layer of the @ai2 design system, built around indeterminate progress for unknown durations. They are free and MIT licensed, and every color comes from a semantic token, so they theme with the rest of ai2 in light and dark.
Motion runs on framer-motion: framer-motion loops the sweeps, marching dashes and comet. The styled layer is opt-in, so the dependency only lands if you use it; the base components stay lean. Under reduced motion, the loops stop and a static partial bar remains.
What is in the ai2 Indeterminate progress?
5 exports in one file: Bar sweep, Dual bar, Pulse track, March and Comet. Each renders a native button and takes a size prop (sm, md, lg, xl) aligned to the base Button. They are separate from the base Button on purpose: the base keeps its clean variant, tone and size axes, while the styled layer carries the effects.
You own the file. Copy the one category file and you have all 5 variations, with no runtime dependency on ai2 itself.
Why use it
- On-system by construction: Every color resolves to an ai2 semantic token, so the buttons follow your theme in light and dark with no extra work.
- Effect without the sprawl: The decorations live in a dedicated styled file, so the base Button keeps its clean, predictable API.
- Accessible and honest: Each renders a real button element, keeps a visible focus ring, and respects prefers-reduced-motion.
Features
- Token-driven color: No hardcoded hex or oklch; the look recolors with your theme tokens.
- framer-motion: framer-motion loops the sweeps, marching dashes and comet.
- Reduced-motion aware: Under prefers-reduced-motion, the loops stop and a static partial bar remains.
- Size aligned to the base: Every variation takes sm, md, lg and xl matching the base Button height scale, so styled and base buttons line up in a row.
Production tips
- Use it for emphasis, not everywhere: Styled buttons draw the eye. Reserve them for the one action you want people to take on a screen, and use the base Button for the rest.
- Keep labels as verbs: The decoration adds weight, so a clear action label keeps the button scannable.
- Pick one variation per surface: The variations share a family; using two different ones in the same view competes for attention.
Works with the rest of ai2
The Indeterminate progress sit alongside the base Button and the rest of the @ai2 registry. They share the same token file, so a styled action next to a base button or a badge stays visually consistent in both modes.