Styled skeleton
Five skeleton bar treatments: a shimmer sweep, a pulse, a wave, a shifting gradient and a glow. Each is sized by height and token-driven, and keeps animating because a frozen placeholder reads as a hang.
Installation
The styled layer is free and installs like any other ai2 component.
Run the following command
npx shadcn@latest add @ai2/skeleton-styledDependencies, the @ai2/tokens theme and the component file are installed together.
Install dependencies
npm install motionCopy the source
components/ui/skeleton-styled.tsx"use client"
import type * as React from "react"
import { motion, useReducedMotion } from "motion/react"
import { cn } from "@/lib/utils"
/* Skeleton family: 5 different SHIMMER treatments of a single token bar (NOT the
shape - what changes is the character of the glow, which deliberately separates
this from the loaders-skeleton shapes). Color comes ONLY from tokens; alpha via
color-mix(in oklab). Size = the bar's HEIGHT; the width defaults to w-full and is
rounded. DELIBERATE: a skeleton keeps animating under reduced-motion too (a
stopped placeholder reads as "stuck", the base Spinner exception). That is why we
do not stop the shimmer. */
export type StyledSize = "sm" | "md" | "lg" | "xl"
const height: Record<StyledSize, string> = {
sm: "h-3",
md: "h-4",
lg: "h-5",
xl: "h-6",
}
type Props = React.ComponentProps<"div"> & { size?: StyledSize }
const base = "relative w-full overflow-hidden rounded-md bg-secondary"
/* Shimmer: yumusak token parlamasi sol->sag supurur (klasik). */
export function ShimmerSkeleton({ className, size = "md", ...props }: Props) {
useReducedMotion()
return (
<div
data-slot="styled-skeleton"
role="status"
aria-label="Loading"
className={cn(base, height[size], className)}
{...props}
>
<motion.span
aria-hidden="true"
className="absolute inset-y-0 left-0 w-2/3 bg-[linear-gradient(90deg,transparent,color-mix(in_oklab,var(--color-foreground)_12%,transparent),transparent)]"
animate={{ x: ["-100%", "250%"] }}
transition={{ duration: 1.4, ease: "easeInOut", repeat: Infinity }}
/>
</div>
)
}
/* Pulse: butun cubuk dongude opaklik nabzi atar. */
export function PulseSkeleton({ className, size = "md", ...props }: Props) {
useReducedMotion()
return (
<div
data-slot="styled-skeleton"
role="status"
aria-label="Loading"
className={cn("relative w-full rounded-md", height[size], className)}
{...props}
>
<motion.span
aria-hidden="true"
className="absolute inset-0 rounded-md bg-secondary"
animate={{ opacity: [0.45, 1, 0.45] }}
transition={{ duration: 1.5, ease: "easeInOut", repeat: Infinity }}
/>
</div>
)
}
/* Wave: a narrow bright band travels with a slight vertical wave/skew. */
export function WaveSkeleton({ className, size = "md", ...props }: Props) {
useReducedMotion()
return (
<div
data-slot="styled-skeleton"
role="status"
aria-label="Loading"
className={cn(base, height[size], className)}
{...props}
>
<motion.span
aria-hidden="true"
className="absolute inset-y-0 left-0 w-1/4 -skew-x-12 bg-[linear-gradient(90deg,transparent,color-mix(in_oklab,var(--color-foreground)_22%,transparent),transparent)]"
animate={{ x: ["-120%", "480%"], y: ["-12%", "12%", "-12%"] }}
transition={{ duration: 1.6, ease: "easeInOut", repeat: Infinity }}
/>
</div>
)
}
/* Gradient: cubugun kendisi yavasca kayan bir token gradyani (backgroundPosition). */
export function GradientSkeleton({ className, size = "md", ...props }: Props) {
useReducedMotion()
return (
<div
data-slot="styled-skeleton"
role="status"
aria-label="Loading"
className={cn("relative w-full overflow-hidden rounded-md", height[size], className)}
{...props}
>
<motion.span
aria-hidden="true"
className="absolute inset-0 bg-[length:200%_100%] bg-[linear-gradient(90deg,var(--color-secondary),color-mix(in_oklab,var(--color-foreground)_14%,var(--color-secondary)),var(--color-secondary))]"
animate={{ backgroundPosition: ["200% 0%", "-200% 0%"] }}
transition={{ duration: 2, ease: "linear", repeat: Infinity }}
/>
</div>
)
}
/* Glow: a glow passes along the leading edge, pulsing with a token light. */
export function GlowSkeleton({ className, size = "md", ...props }: Props) {
useReducedMotion()
return (
<div
data-slot="styled-skeleton"
role="status"
aria-label="Loading"
className={cn(base, height[size], className)}
{...props}
>
<motion.span
aria-hidden="true"
className="absolute inset-y-0 left-0 w-1/5 rounded-full bg-[color-mix(in_oklab,var(--color-foreground)_28%,transparent)] shadow-[0_0_12px_2px_color-mix(in_oklab,var(--color-foreground)_28%,transparent)]"
animate={{ x: ["-140%", "560%"], opacity: [0.4, 1, 0.4] }}
transition={{ duration: 1.8, ease: "easeInOut", repeat: Infinity }}
/>
</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.
Shimmer
A soft token highlight sweeps across.
import { ShimmerSkeleton } from "@/components/ui/skeleton-styled"
<ShimmerSkeleton />Pulse
The bar pulses opacity on a loop.
import { PulseSkeleton } from "@/components/ui/skeleton-styled"
<PulseSkeleton />Wave
A bright band travels with a slight wave.
import { WaveSkeleton } from "@/components/ui/skeleton-styled"
<WaveSkeleton />Gradient
The bar is a slowly shifting token gradient.
import { GradientSkeleton } from "@/components/ui/skeleton-styled"
<GradientSkeleton />Glow
A token glow pulses as a highlight passes.
import { GlowSkeleton } from "@/components/ui/skeleton-styled"
<GlowSkeleton />ai2 Styled skeleton: 5 styled variations on the token system
The ai2 Styled skeleton are a set of 5 decorative button variations from the styled layer of the @ai2 design system, built around loading placeholder shimmers. 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 sweeps the highlight and shifts the gradient. The styled layer is opt-in, so the dependency only lands if you use it; the base components stay lean. Under reduced motion, the shimmer keeps sweeping on purpose, like the base Spinner, because a frozen placeholder reads as a hang.
What is in the ai2 Styled skeleton?
5 exports in one file: Shimmer, Pulse, Wave, Gradient and Glow. 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 sweeps the highlight and shifts the gradient.
- Reduced-motion aware: Under prefers-reduced-motion, the shimmer keeps sweeping on purpose, like the base Spinner, because a frozen placeholder reads as a hang.
- 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 Styled skeleton 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.