shadcn.io is not affiliated with official shadcn/ui
Shadcn Status for React and Tailwind
Color-coded status for process or state.
Installation
bunx --bun shadcn@latest add https://kit.dev/r/status.jsonpnpm dlx shadcn@latest add https://kit.dev/r/status.jsonnpx shadcn@latest add https://kit.dev/r/status.jsonyarn shadcn@latest add https://kit.dev/r/status.jsonInstall the following dependencies:
bun add @ark-ui/react tailwind-variantspnpm add @ark-ui/react tailwind-variantsnpm install @ark-ui/react tailwind-variantsyarn add @ark-ui/react tailwind-variantsImport the following variables into your CSS file
@theme inline {
--color-destructive-foreground: var(--destructive-foreground);
--color-info: var(--info);
--color-info-foreground: var(--info-foreground);
--color-success: var(--success);
--color-success-foreground: var(--success-foreground);
--color-warning: var(--warning);
--color-warning-foreground: var(--warning-foreground);
}
:root {
--destructive-foreground: var(--color-red-700);
--info: var(--color-blue-500);
--info-foreground: var(--color-blue-700);
--success: var(--color-emerald-500);
--success-foreground: var(--color-emerald-700);
--warning: var(--color-amber-500);
--warning-foreground: var(--color-amber-700);
}
.dark {
--destructive-foreground: var(--color-red-400);
--info: var(--color-blue-500);
--info-foreground: var(--color-blue-400);
--success: var(--color-emerald-500);
--success-foreground: var(--color-emerald-400);
--warning: var(--color-amber-500);
--warning-foreground: var(--color-amber-400);
}Copy and paste the following code into your project.
"use client";
import { ark } from "@ark-ui/react/factory";
import type React from "react";
import { tv, type VariantProps } from "tailwind-variants";
import { cn } from "@/lib/utils";
export const statusVariants = tv({
base: [
"shrink-0 rounded-full",
"flex items-center justify-center",
"font-medium text-[10px]",
"ring-2 ring-background",
],
variants: {
variant: {
default: "bg-foreground text-background",
success: "bg-success text-white",
info: "bg-info text-white",
warning: "bg-warning text-white",
destructive: "bg-destructive text-white dark:bg-destructive-foreground",
},
size: {
sm: "size-2 [&_svg:not([class*='size-'])]:size-1.5 [&_svg]:pointer-events-none [&_svg]:shrink-0",
md: "size-2.5 [&_svg:not([class*='size-'])]:size-2 [&_svg]:pointer-events-none [&_svg]:shrink-0",
lg: "size-3 [&_svg:not([class*='size-'])]:size-2.5 [&_svg]:pointer-events-none [&_svg]:shrink-0",
},
},
defaultVariants: {
variant: "default",
size: "md",
},
});
interface StatusProps
extends React.ComponentProps<typeof ark.span>,
VariantProps<typeof statusVariants> {}
export const Status = (props: StatusProps) => {
const { variant, size, className, ...rest } = props;
return (
<ark.span
aria-hidden="true"
className={cn(statusVariants({ variant, size }), className)}
data-size={size}
data-slot="status-indicator"
{...rest}
/>
);
};Update the import paths to match your project setup.
Usage
import { Status } from "@/components/ui/status";<Status variant="success" />Variants
Default
Info
Success
Warning
Destructive
Sizes
Small
Medium
Large
With Badge
With Icon
Place an icon inside the Status.
Custom Size
Use size-* on Status to customize the size.
Custom Color
Use bg-* and text-* utility classes to customize the color.
API Reference
Status
Status badge or indicator.
| Prop | Type | Default |
|---|---|---|
variant | "success" | "info" | "warning" | "destructive" | "success" |
size | "sm" | "md" | "lg" | "md" |
className | string | - |
asChild | boolean | false |