Updated
Status Badge
NewCustomize
Medium
Installation
npx shadcn@latest add https://uibrik.com/r/status-badge.jsonInstall the packages
npm install @tabler/icons-react motion react-use-measureAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/status-badge/status-badge.tsx"use client"; import { IconAlertTriangleFilled, IconCheck, IconCircleDashed, IconEye, IconPlayerPauseFilled } from "@tabler/icons-react"; import { AnimatePresence, motion, useAnimationControls, useReducedMotion } from "motion/react"; import { useEffect, useRef, type CSSProperties, type ReactNode } from "react"; import useMeasure from "react-use-measure"; import { cn } from "@/lib/utils"; const EASE_OUT: [number, number, number, number] = [0.23, 1, 0.32, 1]; export type StatusIcon = "dot" | "pulse" | "spinner" | ReactNode; export type StatusDef = { label: string; color: string; /** "dot", "pulse" (a live dot), "spinner", or any icon. */ icon?: StatusIcon; /** Shake once on arrival, for failures. */ shake?: boolean; }; export const DEFAULT_STATUSES = { draft: { label: "Draft", color: "#737373", icon: <IconCircleDashed /> }, review: { label: "In review", color: "#8b5cf6", icon: <IconEye /> },
Adds the files to
components/uibrik/status-badge and installs @tabler/icons-react, motion and react-use-measure. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/status-badge.Usage
import { StatusBadge } from "@/components/uibrik/status-badge/status-badge";<StatusBadge size="md" // statuses={{}}/>Where to use Status Badge
Deploys and builds
A spinner while building, a live dot once shipped and a shake on failure, all in one pill that never jumps.
Pairs with Status Dashboard
Content workflows
Draft, review and published each have their own icon and colour, so status reads without the label.
Pairs with Data Table
Orders and tickets
The pill eases to its new width, so a table column of statuses changes in place without the row shifting.
Pairs with Activity Log
Props
StatusBadge- status
- Type "draft" | "review" | "building" | "live" | "done" | "paused" | "failed"
- "live"
- Key of the status to show.
- size
- Type "sm" | "md" | "lg"
- "md"
- Height, padding and text size.
- statuses
- Type Record<string, { label; color; icon?; shake? }>
- –
- Your own statuses. icon is "dot", "pulse", "spinner" or any icon; shake makes it shake on arrival.
- className
- Type string
- –
- Classes for the pill.