Logoreact-timeline-editor
API Reference

Cut Overlay API

Complete API reference for the CutOverlay component and splitActionInRow utility.

Overview

CutOverlay provides a visual "blade" that lets users split action blocks at a time precise position.

Requirements:

  1. Mounted as a sibling to <Timeline> inside a position: relative wrapper
  2. Given the same geometry props as <Timeline>

<CutOverlay /> Props

PropTypeRequiredDefaultDescription
dataTimelineRow[]Current timeline data
scalenumber1Duration represented by one scale unit (seconds). Must match the scale prop on <Timeline>.
scaleWidthnumber160Width in pixels of one scale unit. Must match <Timeline> scaleWidth.
scaleSplitCountnumber10Number of sub-divisions per scale unit used for grid snapping. Must match <Timeline> scaleSplitCount.
startLeftnumber20Left inset in pixels before the first scale mark begins. Must match <Timeline> startLeft.
rowHeightnumber32Height in pixels of each row in the edit area. Must match <Timeline> rowHeight.
editAreaTopOffsetnumber32Height in pixels of the time-ruler strip that sits above the edit rows. This is subtracted from the mouse Y coordinate to find the correct row index.
gridSnapbooleanfalseWhen true (and <Timeline gridSnap> is also enabled), the cut point snaps to the nearest grid boundary as the cursor moves.
configCutOverlayConfig{}Fine-grained control over the blade, pill, and block-highlight visuals. All properties are optional and fall back to red-themed defaults.
onModifierChange(isActive: boolean) => voidCalled whenever the keyboard modifier state changes. Fires with true when the modifier is pressed (blade active) and false when released (blade inactive, pointer events pass through). Use this to dynamically control disableDrag on the sibling <Timeline>.
onCut(rowId: string, actionId: string, cutTime: number) => voidCalled when the user clicks while the blade is positioned over an action block. Provides the rowId, actionId, and the exact cutTime in seconds.

CutOverlayConfig

OptionTypeDefaultDescription
bladeColorstring'#ef4444'CSS color of the vertical blade line.
showPillbooleantrueWhether to display the floating time-label pill above the blade. Set to false to completely hide the pill.
formatPillLabel(time: number) => string(t) => `✂ ${t.toFixed(2)}s` Custom formatter for the time label displayed inside the pill. Receives the cut time in seconds and should return a string.
pillColorstring'#ef4444'Background color of the pill label.
pillTextColorstring'#ffffff'Text color of the pill label.
showBlockHighlightbooleantrueWhether to show the translucent highlight on the hovered action block. Set to false to remove all background and border from the clip container.
blockHighlightColorstring'rgba(239,68,68,0.08)'Background fill color for the block highlight. Accepts any valid CSS color value. Only takes effect when showBlockHighlight is true.
blockHighlightBorderColorstring'rgba(239,68,68,0.3)'Border color for the block highlight container. Only takes effect when showBlockHighlight is true.
cursorstring'col-resize'Custom CSS cursor to display when hovering over the active cut overlay. Standard CSS cursors like 'crosshair', 'copy', or 'default' are supported.
keyboardModifier'Alt' | 'Control' | 'Shift' | 'Meta' | string--A specific keyboard key that must be held down to activate the cut blade. Supports standard modifier keys or exact literal character keys (e.g., 'c' or 'x').

splitActionInRow Utility

Immutably splits a single action in a row at a given time. Returns a new TimelineRow[] array.

function splitActionInRow(
  data: TimelineRow[],
  rowId: string,
  actionId: string,
  cutTime: number,
): TimelineRow[];

Parameters

ParameterTypeDescription
dataTimelineRow[]Current timeline data array
rowIdstringID of the row containing the action
actionIdstringID of the action to split
cutTimenumberTime in seconds at which to cut

Return Value

A new TimelineRow[] array with the target action replaced by two new actions:

  • First: [original.start, cutTime)
  • Second: [cutTime, original.end)

Both inherit the same effectId and data from the original.

Example

import { splitActionInRow } from "@keplar-404/react-timeline-editor";

const data: TimelineRow[] = [
  {
    id: "row-1",
    actions: [{ id: "action-1", start: 0, end: 10, effectId: "effect0" }],
  },
];

const newData = splitActionInRow(data, "row-1", "action-1", 5);
// Result: two actions → [0, 5] and [5, 10]
// The original 'action-1' is replaced by two new actions with unique IDs

On this page