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
idstring✅Unique row identifier
actionsTimelineAction[]✅List of action blocks in this row
classNamesstring[]—Additional CSS classes for the row element
selectedboolean—Visual selected state
rowHeightnumber—Override 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
idstring✅—Unique action identifier
startnumber✅—Start time in seconds
endnumber✅—End time in seconds
effectIdstring✅—ID of the effect that governs this action
movableboolean—trueIf false, cannot be dragged horizontally
flexibleboolean—trueIf false, cannot be resized
disabledboolean—falseVisual disabled state
selectedboolean—falseVisual selected state
minStartnumber——Minimum allowed start time (clamps dragging)
maxEndnumber——Maximum allowed end time (clamps dragging)
styleCSSProperties——Inline style for the block element
classNamestring——Additional CSS class
dataany——Custom 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