Badged avatars
Five badged avatars: a notification count, an online status ring, a typing bubble, a NEW chip and a verified check. Each is sized and token-driven.
Installation
The styled layer is free and installs like any other ai2 component.
Run the following command
npx shadcn@latest add @ai2/avatars-badgeDependencies, the @ai2/tokens theme and the component file are installed together.
Install dependencies
npm install motion lucide-reactCopy the source
components/ui/avatars-badge.tsx"use client"
import type * as React from "react"
import { motion, useReducedMotion } from "motion/react"
import { Check } from "lucide-react"
import { cn } from "@/lib/utils"
/* Badge avatar family: 5 decorative avatars carrying a badge or status. Initials-based (no external image) - a consumer can put an <img> in place of the initials. Colour comes ONLY from tokens, size = the box scale. The badges derive from the danger/success/info/brand tokens. The typing dots bounce with framer-motion; static under reduced-motion. */
export type StyledSize = "sm" | "md" | "lg" | "xl"
const box: Record<StyledSize, string> = {
sm: "size-8 text-xs",
md: "size-10 text-sm",
lg: "size-12 text-base",
xl: "size-16 text-lg",
}
const face =
"flex size-full items-center justify-center rounded-full bg-secondary font-medium text-secondary-foreground select-none"
type Props = React.ComponentProps<"div"> & { size?: StyledSize; initials?: string }
/* Notify: sag-ust kosede danger token sayac rozeti. */
export function NotifyAvatar({
className,
size = "md",
initials = "AI",
count = 3,
...props
}: Props & { count?: number }) {
return (
<div data-slot="styled-avatar" className={cn("relative inline-flex", box[size], className)} {...props}>
<span className={face}>{initials}</span>
<span className="absolute -right-1 -top-1 flex min-w-4 items-center justify-center rounded-full border-2 border-background bg-danger px-1 text-[0.625rem] font-semibold leading-none text-danger-foreground select-none">
{count > 99 ? "99+" : count}
</span>
</div>
)
}
/* StatusRing: a full success-token ring marking online (different from the Status dot). */
export function StatusRingAvatar({ className, size = "md", initials = "AI", ...props }: Props) {
return (
<div
data-slot="styled-avatar"
className={cn("relative inline-flex rounded-full ring-2 ring-success ring-offset-2 ring-offset-background", box[size], className)}
{...props}
>
<span className={face}>{initials}</span>
</div>
)
}
/* Typing: alt kosede animasyonlu "yaziyor" nokta baloncugu. */
export function TypingAvatar({ className, size = "md", initials = "AI", ...props }: Props) {
const reduce = useReducedMotion()
return (
<div data-slot="styled-avatar" className={cn("relative inline-flex", box[size], className)} {...props}>
<span className={face}>{initials}</span>
<span className="absolute -bottom-1 -right-1 flex items-center gap-0.5 rounded-full border-2 border-background bg-secondary px-1.5 py-1">
{[0, 1, 2].map((i) => (
<motion.span
key={i}
className="size-1 rounded-full bg-muted-foreground"
animate={reduce ? undefined : { y: [0, -2, 0], opacity: [0.5, 1, 0.5] }}
transition={
reduce ? undefined : { duration: 0.9, ease: "easeInOut", repeat: Infinity, delay: i * 0.15 }
}
/>
))}
</span>
</div>
)
}
/* New: sag-ust kosede kucuk "NEW" token cipi. */
export function NewAvatar({ className, size = "md", initials = "AI", ...props }: Props) {
return (
<div data-slot="styled-avatar" className={cn("relative inline-flex", box[size], className)} {...props}>
<span className={face}>{initials}</span>
<span className="absolute -right-1 -top-1 rounded-full border-2 border-background bg-info px-1.5 text-[0.5rem] font-bold uppercase leading-4 tracking-wide text-info-foreground select-none">
New
</span>
</div>
)
}
/* Verified: sag-alt kosede kucuk check rozeti (info token). */
export function VerifiedAvatar({ className, size = "md", initials = "AI", ...props }: Props) {
return (
<div data-slot="styled-avatar" className={cn("relative inline-flex", box[size], className)} {...props}>
<span className={face}>{initials}</span>
<span className="absolute -bottom-0.5 -right-0.5 flex size-1/3 items-center justify-center rounded-full border-2 border-background bg-info text-info-foreground [&_svg]:size-2/3">
<Check strokeWidth={3} />
</span>
</div>
)
}Manual installs skip the @ai2/tokens theme, so add the token CSS from the theming guide or the tone colors will be missing.
Variations
5 takes on the same idea. Each is its own export, and every one accepts a size prop (sm, md, lg, xl) aligned to the base Button scale.
Notify
A danger-token count badge in the corner.
import { NotifyAvatar } from "@/components/ui/avatars-badge"
<NotifyAvatar />Status ring
A full success-token ring for online.
import { StatusRingAvatar } from "@/components/ui/avatars-badge"
<StatusRingAvatar />Typing
An animated typing-dots bubble.
import { TypingAvatar } from "@/components/ui/avatars-badge"
<TypingAvatar />New
A small NEW token chip.
import { NewAvatar } from "@/components/ui/avatars-badge"
<NewAvatar />Verified
A small check badge.
import { VerifiedAvatar } from "@/components/ui/avatars-badge"
<VerifiedAvatar />ai2 Badged avatars: 5 styled variations on the token system
The ai2 Badged avatars are a set of 5 decorative button variations from the styled layer of the @ai2 design system, built around avatars with status badges. They are free and MIT licensed, and every color comes from a semantic token, so they theme with the rest of ai2 in light and dark.
Motion runs on framer-motion: framer-motion animates the typing bubble; the rest are static. The styled layer is opt-in, so the dependency only lands if you use it; the base components stay lean. Under reduced motion, the typing dots stop and the badges stay still.
What is in the ai2 Badged avatars?
5 exports in one file: Notify, Status ring, Typing, New and Verified. Each renders a native button and takes a size prop (sm, md, lg, xl) aligned to the base Button. They are separate from the base Button on purpose: the base keeps its clean variant, tone and size axes, while the styled layer carries the effects.
You own the file. Copy the one category file and you have all 5 variations, with no runtime dependency on ai2 itself.
Why use it
- On-system by construction: Every color resolves to an ai2 semantic token, so the buttons follow your theme in light and dark with no extra work.
- Effect without the sprawl: The decorations live in a dedicated styled file, so the base Button keeps its clean, predictable API.
- Accessible and honest: Each renders a real button element, keeps a visible focus ring, and respects prefers-reduced-motion.
Features
- Token-driven color: No hardcoded hex or oklch; the look recolors with your theme tokens.
- framer-motion: framer-motion animates the typing bubble; the rest are static.
- Reduced-motion aware: Under prefers-reduced-motion, the typing dots stop and the badges stay still.
- Size aligned to the base: Every variation takes sm, md, lg and xl matching the base Button height scale, so styled and base buttons line up in a row.
Production tips
- Use it for emphasis, not everywhere: Styled buttons draw the eye. Reserve them for the one action you want people to take on a screen, and use the base Button for the rest.
- Keep labels as verbs: The decoration adds weight, so a clear action label keeps the button scannable.
- Pick one variation per surface: The variations share a family; using two different ones in the same view competes for attention.
Works with the rest of ai2
The Badged avatars sit alongside the base Button and the rest of the @ai2 registry. They share the same token file, so a styled action next to a base button or a badge stays visually consistent in both modes.