--- name: skeleton-loaders description: Builds skeleton loading states that are pixel-perfect matches of real content. Use this skill whenever adding loading states to components, building skeletons for async data, handling pending loader states in route transitions, or implementing the shimmer animation pattern. Also trigger when the user asks about preventing layout shift during data fetching. --- # Skeleton Loaders Contents: Transparent Text Technique; 200ms Delay Pattern; Accessibility. ## Transparent Text Technique Use real HTML elements (`

`, ``, `

`, ` ``` ## 200ms Delay Pattern Avoid skeleton flash on fast loads. Show stale/empty content for 200ms before revealing the skeleton: ```tsx const [showSkeleton, setShowSkeleton] = useState(false); // Valid Effect: synchronizing component state with a timer (external system). // The cleanup prevents a state update after unmount. useEffect(() => { const timer = setTimeout(() => setShowSkeleton(true), 200); return () => clearTimeout(timer); }, []); if (!showSkeleton) return null; // or return stale content return ; ``` ## Accessibility Skeleton text is transparent, but screen readers still announce it (placeholder text and any `t()` labels). Hide the skeleton from assistive tech and announce loading instead: - Put `aria-hidden` on the skeleton's root element so assistive tech skips the decorative placeholders. - Mark the region that will receive the content with `aria-busy="true"` while loading, or render a visually-hidden `role="status"` "Loading" message so screen-reader users know content is on the way.