Code Accordion

A code window that springs a range of lines closed and replaces them with a "N lines collapsed" placeholder

Installation

$ pnpm dlx shadcn@latest add @remocn/code-accordion

Usage

// src/Root.tsx
import { Composition } from "remotion";
import { CodeAccordion } from "@/components/remocn/code-accordion";

const CodeAccordionScene = () => (
  <CodeAccordion
    lines={fileContents.split("\n")}
    collapseRange={[3, 14]}
    collapseAt={30}
  />
);

export const RemotionRoot = () => (
  <Composition
    id="CodeAccordion"
    component={CodeAccordionScene}
    durationInFrames={150}
    fps={30}
    width={1280}
    height={720}
  />
);

Props

PropTypeDefaultDescription
lines
string[]Lines of code to render. Pre-split into an array.
collapseRange
[number, number][3, 14]Inclusive 0-based start and end line indices that will collapse
collapseAt
number30Frame at which the collapse spring fires
title
string"process-orders.ts"Filename shown in the chrome bar
fontSize
number16Code font size in pixels
width
number720Window width in pixels
background
string"#050505"Page background color
cardColor
string"#0a0a0a"Editor surface color
textColor
string"#e4e4e7"Code color
mutedColor
string"#52525b"Line numbers and placeholder bar color
speed
number1Playback speed multiplier
className
stringOptional className passed to the root container