Status dot
A small dot before a word that names a state: a service, a device, a connection. A state that is live right now can pulse. For a label with a filled shape use the badge; for a person's presence use the avatar's status.
Install
npx shadcn@latest add https://thrumui.dev/r/status-dot.jsonAdds components/ui/status-dot.tsx. Nothing else in your project changes.
import { StatusDot } from "@/components/ui/status-dot";Props
| Prop | Type | Default | Description |
|---|---|---|---|
status | "ok" | "warning" | "critical" | "info" | "neutral" | "offline" | Default "neutral" | The state. ok, warning and critical use the theme's status colours, info the text colour, neutral the muted text colour. offline is a hollow ring. |
pulse | boolean | Default false | A ring grows out of the dot and fades, every 1.6 seconds. Use it for a state that is live right now. offline never pulses. |
paused | boolean | Default false | Freeze the pulse where it is. |
children | ReactNode | – | The label. It is required: it names the state, so the state never rests on colour alone. A long one wraps beside the dot. |
aria-label | string | – | For a dot with no children, in a dense table for example. The dot is then an image with this name. |
className | string | – | Extra classes, merged last. The dot is half the font size: text-sm gives a 7 pixel dot, text-base an 8 pixel one. |
...props | ComponentProps<"span"> | – | Every other span attribute is passed through. |
Motion and sound
Motion
- With pulse, a ring of the dot's colour grows from the dot to 2.75 times its size while it fades from 60% to nothing, in 1.6 seconds, and repeats.
- The ring is out of the layout: nothing beside the dot moves.
- paused freezes the ring where it is. A dot that starts paused shows no ring.
- Reduced motion: no ring. The dot is still.
Sound
Silent. This component makes no sound.
Accessibility
- The dot is hidden from screen readers. The label is read as plain text, so it must name the state: “Operational”, not “API”.
- Six states differ in colour, and offline also in shape: a ring where the others are a disc. The word is what tells them apart for everyone.
- With no children and an aria-label, the whole component is an image with that name.
- It is not a live region. Where a change of state must be announced, put it inside an element with aria-live.
- A pulse that never stops draws the eye away from reading. Keep it for one or two states a view is about.
Source
"use client";
import type { ComponentProps } from "react";
import { cn } from "@/lib/utils";
import { STATUS } from "@/lib/thrum-chart";
export type StatusDotStatus = "ok" | "warning" | "critical" | "info" | "neutral" | "offline";
export type StatusDotProps = ComponentProps<"span"> & {
/** The state the dot stands for. It sets the colour; `offline` is a hollow ring. */
status?: StatusDotStatus;
/** A ring that grows out of the dot and fades, every 1.6 seconds: for a state that is live right now. `offline` never pulses. */
pulse?: boolean;
/** Freeze the pulse where it is. */
paused?: boolean;
};
const COLOR: Record<StatusDotStatus, string> = {
ok: STATUS.ok,
warning: STATUS.warn,
critical: STATUS.alarm,
info: STATUS.normal,
neutral: "var(--muted-foreground)",
offline: "var(--muted-foreground)",
};
/**
* A dot before a word that names a state: "Operational", "Degraded", "Offline".
* The dot is half as tall as the text and takes its size from it. The children are the label, and they are required:
* without them, pass an `aria-label` and the dot becomes an image with that name.
*/
export function StatusDot({ status = "neutral", pulse = false, paused = false, className, children, ...props }: StatusDotProps) {
const hollow = status === "offline";
const bare = children === undefined || children === null;
return (
<span data-slot="status-dot" data-status={status} role={bare ? "img" : undefined} className={cn("inline-flex max-w-full items-start gap-[0.5em]", className)} {...props}>
{/* One line tall, so the dot sits beside the first line of a label that wraps. */}
<span aria-hidden="true" className="inline-flex h-[1lh] flex-none items-center" style={{ color: COLOR[status] }}>
<span className="relative inline-flex size-[0.5em]">
{pulse && !hollow && (
<span
data-slot="status-dot-pulse"
// At rest, and under reduced motion, the ring is not drawn at all.
className={cn(
"absolute inset-0 rounded-full bg-current opacity-0 animate-[status-dot-pulse_1.6s_ease-out_infinite] motion-reduce:animate-none",
paused && "[animation-play-state:paused]",
)}
/>
)}
<span className={cn("relative size-full rounded-full", hollow ? "border-[0.125em] border-current" : "bg-current")} />
</span>
</span>
{!bare && <span className="min-w-0">{children}</span>}
</span>
);
}Files and dependencies
- Adds
components/ui/status-dot.tsx- Packages
- None
- Brings along
- Chart foundations
Changelog
- 1.0.0 · 2026-12-03First release.