Shimmer
shadcn-extras/shimmerFreeComponent
Shimmer/skeleton loading components: line, avatar, card, rect, list.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/NayanDevLab/shadcn-extras/dev/public/c/shimmer.jsonSource
1// components/core/shimmer-skeleton.tsx2'use client';34import * as React from 'react';5import { motion } from 'motion/react';6import { cn } from '@/lib/utils';78export type ShimmerVariant = 'line' | 'avatar' | 'card' | 'rect' | 'list';910export type ShimmerProps = {11 /** Which visual variant to render. */12 variant?: ShimmerVariant;1314 /** Number of repeated items (useful for lists). */15 count?: number;1617 /** Width as Tailwind friendly string or number (px). Applied to top-level when relevant. */18 width?: string | number;1920 /** Height as Tailwind friendly string or number (px). Applied to top-level when relevant. */21 height?: string | number;2223 /** Rounded corners style. */24 rounded?: 'none' | 'sm' | 'md' | 'lg' | 'full';2526 /** Tailwind color for base (e.g. 'bg-zinc-200 dark:bg-zinc-700') - accepts classes. */27 baseClassName?: string;2829 /** Tailwind color for shimmer highlight (applied via gradient stop). */30 highlightClassName?: string;3132 /** Animation speed multiplier (1 = default). */33 speed?: number;3435 /** Gap between items when count > 1 (px). */36 gap?: number;3738 /** Custom className on each item. */39 className?: string;4041 /** When true, makes element accessible for screen readers with label. */42 ariaLabel?: string | null;4344 /** If true, use reduced-motion friendly static style. */45 reduceMotion?: boolean;46};4748const ROUND_MAP: Record<string, string> = {49 none: 'rounded-none',50 sm: 'rounded-sm',51 md: 'rounded-md',52 lg: 'rounded-lg',53 full: 'rounded-full',54};5556function pxOrString(v?: string | number) {57 if (v === undefined) return undefined;58 return typeof v === 'number' ? `${v}px` : v;59}6061/**62 * Shimmer/Skeleton component63 *64 * - Presentational, repeatable, accessible65 * - Use variant + count to produce multi-line lists/cards etc66 */67export default function Shimmer({68 variant = 'line',69 count = 1,70 width,71 height,72 rounded = 'md',73 baseClassName = 'bg-zinc-200 dark:bg-zinc-700',74 // highlightClassName = 'bg-white/70',75 speed = 1,76 gap = 12,77 className,78 ariaLabel = null,79 reduceMotion = false,80}: ShimmerProps) {81 // animation duration in seconds82 const duration = Math.max(0.6, 1.6 / Math.max(0.25, speed));8384 const itemStyle: React.CSSProperties = {85 width: pxOrString(width),86 height: pxOrString(height),87 marginBottom: count > 1 ? `${gap}px` : undefined,88 };8990 // helper render single item depending on variant91 const renderItem = (i: number) => {92// … truncated
What it pulls in
npm packages
Files it writes
More from shadcn-extras
All 33 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Image Gridanimated-image-grid | shadcn-extras | Components | Free | no deps · 3 files | |
| Blog Card Fourblog-card-four | shadcn-extras | Components | Free | 1 dep | |
| Blog Card Oneblog-card-one | shadcn-extras | Components | Free | no deps | |
| Blog Card Threeblog-card-three | shadcn-extras | Components | Free | 1 dep | |
| Blog Card Twoblog-card-two | shadcn-extras | Components | Free | 1 dep | |
| Bulb Iconbulb-icon | shadcn-extras | Components | Free | 2 deps | |
| Chevron Stepschevron-steps | shadcn-extras | Components | Free | no deps | |
| Circular Gallerycircular-gallery | shadcn-extras | Components | Free | no deps · 3 files |
