Card skeletons
Five composite card layouts: a media card, a profile card, a list, a tile grid and an article. Each one blocks out a whole card on the token surface, so the placeholder matches the shape of the content that is about to land.
Installation
The styled layer is free and installs like any other ai2 component.
Run the following command
npx shadcn@latest add @ai2/skeleton-cardDependencies, the @ai2/tokens theme and the component file are installed together.
Install dependencies
npm install motionCopy the source
components/ui/skeleton-card.tsx"use client"
import type * as React from "react"
import { motion, useReducedMotion } from "motion/react"
import { cn } from "@/lib/utils"
/* Card skeleton family: 5 composite card layouts (media card, profile card, list, grid, article). The difference is not in the ANIMATION but in the STRUCTURE - every variant builds a different card skeleton; the pulse is the same calm token pulse in all of them. The widths are fixed and the delays index-derived (NO Math.random, deterministic SSR). Colour comes ONLY from tokens. Skeletons are decorative: the root is aria-hidden. The pulse stops under reduced motion. */
export type StyledSize = "sm" | "md" | "lg" | "xl"
type Props = React.ComponentProps<"div"> & { size?: StyledSize }
/* Shared calm pulse (framer-motion, NO keyframes). */
function Block({ className, delay = 0 }: { className?: string; delay?: number }) {
const reduce = useReducedMotion()
return (
<motion.span
className={cn("block rounded-md bg-secondary", className)}
animate={reduce ? undefined : { opacity: [0.5, 1, 0.5] }}
transition={
reduce ? undefined : { duration: 1.6, ease: "easeInOut", repeat: Infinity, delay }
}
/>
)
}
const line: Record<StyledSize, string> = {
sm: "h-2.5",
md: "h-3",
lg: "h-3.5",
xl: "h-4",
}
const head: Record<StyledSize, string> = {
sm: "h-3.5",
md: "h-4",
lg: "h-5",
xl: "h-6",
}
const media: Record<StyledSize, string> = {
sm: "h-20",
md: "h-28",
lg: "h-36",
xl: "h-44",
}
const avatar: Record<StyledSize, string> = {
sm: "size-8",
md: "size-10",
lg: "size-12",
xl: "size-14",
}
const gap: Record<StyledSize, string> = {
sm: "gap-2",
md: "gap-3",
lg: "gap-3.5",
xl: "gap-4",
}
const pad: Record<StyledSize, string> = {
sm: "p-3",
md: "p-4",
lg: "p-5",
xl: "p-6",
}
/* Her varyantin kabugu: token yuzeyi + kenarlik. */
const card = "flex w-full flex-col rounded-xl border border-border bg-card"
/* Media: an image area on top, a title plus two lines below. */
export function MediaSkeleton({ className, size = "md", ...props }: Props) {
return (
<div
data-slot="styled-skeleton"
aria-hidden="true"
className={cn(card, "overflow-hidden", className)}
{...props}
>
<Block className={cn("w-full rounded-none", media[size])} />
<div className={cn("flex flex-col", gap[size], pad[size])}>
<Block className={cn("w-2/3 rounded-lg", head[size])} delay={0.12} />
<Block className={cn("w-full", line[size])} delay={0.24} />
<Block className={cn("w-4/5", line[size])} delay={0.36} />
</div>
</div>
)
}
/* Profile: a centred avatar, a name, a second line and two action pills. */
export function ProfileSkeleton({ className, size = "md", ...props }: Props) {
return (
<div
data-slot="styled-skeleton"
aria-hidden="true"
className={cn(card, "items-center text-center", gap[size], pad[size], className)}
{...props}
>
<Block className={cn("rounded-full", avatar[size])} />
<Block className={cn("w-1/2 rounded-lg", head[size])} delay={0.12} />
<Block className={cn("w-2/3", line[size])} delay={0.24} />
<div className={cn("flex w-full items-center justify-center", gap[size])}>
<Block className={cn("w-20 rounded-full", head[size])} delay={0.36} />
<Block className={cn("w-20 rounded-full", head[size])} delay={0.48} />
</div>
</div>
)
}
/* List: n rows, each a small thumbnail plus two lines of text. */
export function ListSkeleton({
className,
size = "md",
count = 3,
...props
}: Props & { count?: number }) {
return (
<div
data-slot="styled-skeleton"
aria-hidden="true"
className={cn(card, gap[size], pad[size], className)}
{...props}
>
{Array.from({ length: count }, (_, i) => (
<div key={i} className={cn("flex w-full items-center", gap[size])}>
<Block className={cn("shrink-0 rounded-lg", avatar[size])} delay={i * 0.12} />
<div className={cn("flex min-w-0 flex-1 flex-col", "gap-2")}>
<Block className={cn("w-1/2", head[size])} delay={i * 0.12 + 0.06} />
<Block className={cn("w-4/5", line[size])} delay={i * 0.12 + 0.12} />
</div>
</div>
))}
</div>
)
}
/* Grid: a two-column tile grid, each tile an image plus one line. */
export function GridSkeleton({
className,
size = "md",
count = 4,
...props
}: Props & { count?: number }) {
return (
<div
data-slot="styled-skeleton"
aria-hidden="true"
className={cn("grid w-full grid-cols-2", gap[size], className)}
{...props}
>
{Array.from({ length: count }, (_, i) => (
<div key={i} className={cn(card, "overflow-hidden")}>
<Block className={cn("w-full rounded-none", media[size])} delay={i * 0.12} />
<div className={cn("flex flex-col gap-2", pad[size])}>
<Block className={cn("w-3/4", head[size])} delay={i * 0.12 + 0.06} />
<Block className={cn("w-1/2", line[size])} delay={i * 0.12 + 0.12} />
</div>
</div>
))}
</div>
)
}
/* Article: kapak gorseli, baslik, paragraf ve yazar satiri. */
export function ArticleSkeleton({ className, size = "md", ...props }: Props) {
return (
<div
data-slot="styled-skeleton"
aria-hidden="true"
className={cn(card, "overflow-hidden", className)}
{...props}
>
<Block className={cn("w-full rounded-none", media[size])} />
<div className={cn("flex flex-col", gap[size], pad[size])}>
<Block className={cn("w-5/6 rounded-lg", head[size])} delay={0.12} />
<Block className={cn("w-full", line[size])} delay={0.24} />
<Block className={cn("w-11/12", line[size])} delay={0.36} />
<Block className={cn("w-3/5", line[size])} delay={0.48} />
<div className={cn("mt-1 flex items-center border-t border-border pt-3", gap[size])}>
<Block className={cn("shrink-0 rounded-full", avatar[size])} delay={0.6} />
<div className="flex min-w-0 flex-1 flex-col gap-2">
<Block className={cn("w-1/3", line[size])} delay={0.66} />
<Block className={cn("w-1/4", line[size])} delay={0.72} />
</div>
</div>
</div>
</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.
Media
A cover area over a title and two lines.
import { MediaSkeleton } from "@/components/ui/skeleton-card"
<MediaSkeleton />Profile
A centered avatar, name and two actions.
import { ProfileSkeleton } from "@/components/ui/skeleton-card"
<ProfileSkeleton />List
Rows of a thumbnail beside two text lines.
import { ListSkeleton } from "@/components/ui/skeleton-card"
<ListSkeleton />Grid
A two column grid of media tiles.
import { GridSkeleton } from "@/components/ui/skeleton-card"
<GridSkeleton />Article
A cover, heading, paragraph and author row.
import { ArticleSkeleton } from "@/components/ui/skeleton-card"
<ArticleSkeleton />ai2 Card skeletons: 5 styled variations on the token system
The ai2 Card skeletons are a set of 5 decorative button variations from the styled layer of the @ai2 design system, built around composite card layouts that block out a whole card, not a single bar. 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 runs one calm opacity pulse, staggered across the blocks. The styled layer is opt-in, so the dependency only lands if you use it; the base components stay lean. Under reduced motion, the pulse stops and the layout stays static.
What is in the ai2 Card skeletons?
5 exports in one file: Media, Profile, List, Grid and Article. 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 runs one calm opacity pulse, staggered across the blocks.
- Reduced-motion aware: Under prefers-reduced-motion, the pulse stops and the layout stays static.
- 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 Card skeletons 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.