Skip to content
caliper ui docs

Components

Loader

A small indeterminate indicator in four shapes.

Free
pnpm dlx shadcn@latest add @caliper/loader

Activity

Short waits with nothing to measure

  • Importing 1,284 contacts
  • Mara Chen is typing
  • Building preview for #2290
  • Drafting a reply
Installs components/ui/loader.tsxDepends on none beyond ReactMotion none in component source

When to use

Use it for

  • Short waits where there is nothing measurable to show.
  • Inline beside a label or inside a control.

Skip it when

  • You can show real progress; use a progress bar.
  • A whole region is loading; use a skeleton.

Installation

terminal
pnpm dlx shadcn@latest add @caliper/loader

Adds its 2 files to components/ui/, each with its own stylesheet, and installs their packages. No account needed. The first part also adds Caliper UI’s tokens; import them once as in Installation.

Usage

This is the code behind the preview above.

example.tsx
import { type ReactNode } from "react"
import { cn } from "@/components/ui/lib/cn"
import { Loader } from "@/components/ui/loader"

function Panel({ title, context, action, className, children }: { title: string; context: string; action?: ReactNode; className?: string; children: ReactNode }) {
  return (
    <section className={cn("grid w-full max-w-md gap-5 rounded-overlay border border-border bg-background p-6 shadow-resting", className)}>
      <div className="flex items-start justify-between gap-3">
        <div className="grid min-w-0 gap-1">
          <p className="font-medium">{title}</p>
          <p className="text-sm text-muted-foreground">{context}</p>
        </div>
        {action}
      </div>
      {children}
    </section>
  );
}

export function LoaderShapes() {
  const jobs = [
    { label: "Importing 1,284 contacts", variant: "spinner" },
    { label: "Mara Chen is typing", variant: "dots" },
    { label: "Building preview for #2290", variant: "bars" },
    { label: "Drafting a reply", variant: "morph" },
  ] as const;
  return (
    <Panel title="Activity" context="Short waits with nothing to measure">
      <ul className="grid divide-y divide-border">
        {jobs.map((job) => (
          <li key={job.variant} className="flex items-center justify-between gap-4 py-3 text-sm first:pt-0 last:pb-0">
            <span>{job.label}</span>
            <Loader variant={job.variant} label={job.label} />
          </li>
        ))}
      </ul>
    </Panel>
  );
}

API reference

Loader

component

Also accepts the native props of its root element and a ref.

PropTypeDefault
variantLoaderVariant"spinner"
sizenumber20
labelstring"Loading"

Accessibility

It exposes status semantics, with aria-label kept in step with state. Changes that matter are announced through a live region.

No custom key handling; Tab and the native activation keys do the work.

Motion

It declares no animation in its component source. Any transition comes from its stylesheet, which uses the duration tokens that collapse to instant under prefers-reduced-motion.

All Feedback examples