Logoreact-timeline-editor
API Reference

Data Interface Reference

Complete TypeScript reference for TimelineRow, TimelineAction, and TimelineEffect.

TimelineRow

export interface TimelineRow {
  id: string;
  actions: TimelineAction[];
  classNames?: string[];
  selected?: boolean;
  rowHeight?: number;
}
PropertyTypeRequiredDescription
idstringUnique row identifier
actionsTimelineAction[]List of action blocks in this row
classNamesstring[]Additional CSS classes for the row element
selectedbooleanVisual selected state
rowHeightnumberOverride the global rowHeight for this row

TimelineAction

export interface TimelineAction {
  id: string;
  start: number;
  end: number;
  effectId: string;
  movable?: boolean;
  flexible?: boolean;
  disabled?: boolean;
  selected?: boolean;
  minStart?: number;
  maxEnd?: number;
  style?: React.CSSProperties;
  className?: string;
  data?: any;
}
PropertyTypeRequiredDefaultDescription
idstringUnique action identifier
startnumberStart time in seconds
endnumberEnd time in seconds
effectIdstringID of the effect that governs this action
movablebooleantrueIf false, cannot be dragged horizontally
flexiblebooleantrueIf false, cannot be resized
disabledbooleanfalseVisual disabled state
selectedbooleanfalseVisual selected state
minStartnumberMinimum allowed start time (clamps dragging)
maxEndnumberMaximum allowed end time (clamps dragging)
styleCSSPropertiesInline style for the block element
classNamestringAdditional CSS class
dataanyCustom metadata payload

TimelineEffect

export interface TimelineEffect {
  id: string;
  name: string;
  source?: TimeLineEffectSource;
}

export interface TimeLineEffectSource {
  start?: (params: EffectSourceParams) => void;
  enter?: (params: EffectSourceParams) => void;
  update?: (params: EffectSourceParams) => void;
  leave?: (params: EffectSourceParams) => void;
  stop?: (params: EffectSourceParams) => void;
}

export interface EffectSourceParams {
  action: TimelineAction;
  row: TimelineRow;
  engine: TimelineEngine;
  isPlaying: boolean;
  time: number;
}
CallbackWhen it firesCan return false?
startPlayback begins while cursor is inside the actionNo
enterPlayhead crosses into the actionNo
updateEvery tick while inside the actionNo
leavePlayhead crosses out of the actionNo
stopPlayback is paused inside the actionNo

Complete Example

import { TimelineRow, TimelineEffect } from "@keplar-404/react-timeline-editor";

// Extend TimelineAction for custom data
interface MyAction extends TimelineAction {
  data: {
    name: string;
    src: string;
  };
}

const effects: Record<string, TimelineEffect> = {
  audio: {
    id: "audio",
    name: "Play Audio",
    source: {
      enter: ({ action, time }) => {
        // Start playing audio at (time - action.start) offset
        console.log("Starting audio:", (action as MyAction).data.src);
      },
      leave: ({ action }) => {
        console.log("Stopping audio:", (action as MyAction).data.src);
      },
    },
  },
};

const editorData: TimelineRow[] = [
  {
    id: "audio-track",
    actions: [
      {
        id: "audio-clip-1",
        start: 0,
        end: 10,
        effectId: "audio",
        data: { name: "Background Music", src: "/audio/bg.mp3" },
      } as MyAction,
    ],
  },
];

On this page