Components/AI

Animated Code List

Animated list of code lines with skeleton loading, progressive reveal, continuous scrolling, and virtualization for large datasets, powered by a custom hook

Preview

Live Preview
Open in

Generating code for your application

Example

export default function AnimatedCodeListExample() {
  const codeLines = [
    "function processData(data) {",
    "  const results = [];",
    "  for (let i = 0; i < data.length; i++) {",
    "    const item = data[i];",
    "    if (item.isValid) {",
    "      results.push(item.process());",
    "    }",
    "  }",
    "  return results;",
    "}",
    "",
    "// Example usage",
    "const data = [",
    "  { id: 1, isValid: true, process: () => 'processed' },",
    "  { id: 2, isValid: false, process: () => 'skipped' },",
    "  { id: 3, isValid: true, process: () => 'processed' },",
    "];",
    "",
    "const result = processData(data);",
    "console.log(result); // ['processed', 'processed']",
  ];

  return (
    <AnimatedCodeList
      title="Generating code for your application..."
      codeLines={codeLines}
      animationSpeed="normal"
      scrollDirection="up"
      scrollDuration={25000} // Custom 25 second duration
      scrollCadence="stepped"
      pauseDuration={1500}
      skeletonDuration={2000}
      lineRevealDelay={150}
      containerHeight={288}
      startLineNumber={1}
      className="w-full max-w-lg"
    />
  );
}

Documentation

PropTypeDefaultDescription
titlestring"Generating code for your application"Title displayed at the top
codeLinesstring[][]Array of code lines to display
classNamestringundefinedAdditional CSS classes for styling
scrollDirection"up" | "down""up"Direction of the scrolling animation
animationSpeed"slow" | "normal" | "fast""normal"Animation speed (smooth mode uses much slower values)
scrollDurationnumberundefinedCustom animation duration in milliseconds (overrides animationSpeed)
scrollCadence"smooth" | "stepped""smooth"Animation style: "smooth" for continuous infinite scroll, "stepped" for infinite stepped scroll
pauseDurationnumber200Pause duration between scroll steps in ms (only used with "stepped" cadence)
skeletonDurationnumber150Duration of skeleton phase in ms
lineRevealDelaynumber10Delay between each line reveal in ms
containerHeightnumber288Height of the container in pixels (18rem = 288px)
startLineNumbernumber1Starting line number for code display

Types

interface AnimatedCodeListProps {
  title?: string;
  codeLines?: string[];
  className?: string;
  scrollDirection?: "up" | "down";
  animationSpeed?: "slow" | "normal" | "fast";
  scrollDuration?: number;
  scrollCadence?: "smooth" | "stepped";
  pauseDuration?: number;
  skeletonDuration?: number;
  lineRevealDelay?: number;
  containerHeight?: number;
  startLineNumber?: number;
}

Features

  • Skeleton Loading: Animated placeholders during initial load.
  • Progressive Reveal: Code lines fade in one by one.
  • Infinite Scrolling: Both smooth and stepped modes loop infinitely for continuous code generation effect.
  • Line Numbering: Auto-numbered code lines, starting from 112.
  • Responsive Design: Scales for all screen sizes.
  • Dark Mode Support: Compatible color schemes.
  • Customizable Timing: Adjust skeleton, reveal, scroll, and pause durations.
  • Accessibility: Screen reader friendly with semantic structure.
  • Virtualization: Efficiently handles large datasets (e.g., hundreds or thousands of code lines) by rendering only visible items.
  • Custom Hook: Uses useCodeListAnimation for cleaner, reusable logic.