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-variantsAdd the following to your globals.css.
: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";<div className="flex gap-4">
<Status />
<Status variant="success" />
<Status variant="info" />
<Status variant="warning" />
<Status variant="destructive" />
</div>Demos
Custom Color
Custom Size
Size Lg
Size Md
Size Sm
Variant Default
Variant Destructive
Variant Info
Variant Success
Variant Warning
With Badge
With Icon
API Reference
Status
span
PropType
AttributeType