Avatars
Five avatar treatments: a token ring, a presence status, a rotating gradient ring, a glow and a squircle. Each is sized and token-driven, and initials-based so no external image is required.
Installation
The styled layer is free and installs like any other ai2 component.
Run the following command
npx shadcn@latest add @ai2/avatars-styledDependencies, the @ai2/tokens theme and the component file are installed together.
Install dependencies
npm install motionCopy the source
components/ui/avatars-styled.tsx"use client"
import type * as React from "react"
import { motion, useReducedMotion } from "motion/react"
import { cn } from "@/lib/utils"
/* Avatar family: 5 decorative avatars. Initials-based (no external image), colour comes ONLY from tokens. Size = the box scale. framer-motion is used only for the GradientRing rotation; static under reduced-motion. A consumer who wants an image puts an <img> in place of the initials. */
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 }
/* Ring: token halka + bosluk (ring-offset). */
export function RingAvatar({ className, size = "md", initials = "AI", ...props }: Props) {
return (
<div
data-slot="styled-avatar"
className={cn("relative inline-flex rounded-full ring-2 ring-primary ring-offset-2 ring-offset-background", box[size], className)}
{...props}
>
<span className={face}>{initials}</span>
</div>
)
}
/* Status: sag-alt kosede success token durum noktasi. */
export function StatusAvatar({ 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 right-0 size-1/4 rounded-full border-2 border-background bg-success" />
</div>
)
}
/* GradientRing: donen konik token gradyan halka. */
export function GradientRingAvatar({ className, size = "md", initials = "AI", ...props }: Props) {
const reduce = useReducedMotion()
return (
<div data-slot="styled-avatar" className={cn("relative inline-flex rounded-full p-[2px]", box[size], className)} {...props}>
<motion.span
aria-hidden="true"
className="absolute inset-0 rounded-full"
style={{ background: "conic-gradient(from 0deg, var(--info), var(--brand), var(--success), var(--info))" }}
animate={reduce ? undefined : { rotate: 360 }}
transition={reduce ? undefined : { duration: 4, ease: "linear", repeat: Infinity }}
/>
<span className={cn(face, "relative border-2 border-background")}>{initials}</span>
</div>
)
}
/* Glow: yumusak token hale. */
export function GlowAvatar({ className, size = "md", initials = "AI", ...props }: Props) {
return (
<div data-slot="styled-avatar" className={cn("relative inline-flex", box[size], className)} {...props}>
<span aria-hidden="true" className="absolute inset-0 rounded-full bg-brand opacity-50 blur-md" />
<span className={cn(face, "relative bg-brand text-brand-foreground")}>{initials}</span>
</div>
)
}
/* Squircle: superellipse kose + token kenar. */
export function SquircleAvatar({ className, size = "md", initials = "AI", ...props }: Props) {
return (
<div
data-slot="styled-avatar"
className={cn("relative inline-flex rounded-[35%] border border-border bg-secondary", box[size], className)}
{...props}
>
<span className="flex size-full items-center justify-center rounded-[35%] font-medium text-secondary-foreground select-none">
{initials}
</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.
Ring
A token ring with an offset gap.
import { RingAvatar } from "@/components/ui/avatars-styled"
<RingAvatar initials="AI" />Status
A success-token presence dot in the corner.
import { StatusAvatar } from "@/components/ui/avatars-styled"
<StatusAvatar initials="AI" />Gradient ring
A rotating conic token gradient ring.
import { GradientRingAvatar } from "@/components/ui/avatars-styled"
<GradientRingAvatar initials="AI" />Glow
A soft token halo behind the avatar.
import { GlowAvatar } from "@/components/ui/avatars-styled"
<GlowAvatar initials="AI" />Squircle
A superellipse shape with a token border.
import { SquircleAvatar } from "@/components/ui/avatars-styled"
<SquircleAvatar initials="AI" />ai2 Avatars: 5 styled variations on the token system
The ai2 Avatars are a set of 5 decorative button variations from the styled layer of the @ai2 design system, built around avatar decoration. 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 rotates the gradient ring; 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 gradient ring stops rotating and the avatars stay still.
What is in the ai2 Avatars?
5 exports in one file: Ring, Status, Gradient ring, Glow and Squircle. 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 rotates the gradient ring; the rest are static.
- Reduced-motion aware: Under prefers-reduced-motion, the gradient ring stops rotating and the avatars 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 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.