Skip to content

<Layer> ​

Free code in the frame: any React, CSS, canvas or WebGL, placed on the timeline like any overlay; useT() is its time.

tsx
import { Clip, Composition, Layer, Track, useLayer } from "@cutcraft/kit";

export default function Video() {
  return (
    <Composition fps={30} width={960} height={540}>
      <Track id="main">
        <Clip id="shot" src="asset:aurora" in={0} out={3} fit="cover" />
      </Track>
      <Track id="layers">
        <Layer id="clock" anchor="shot" duration={3}>
          <Elapsed />
        </Layer>
      </Track>
    </Composition>
  );
}

/** Any React inside a layer, drawn each frame; `useLayer().elapsed` is the seconds since it started (`useT()` is 0..1). */
function Elapsed() {
  const t = useLayer().elapsed;
  return (
    <div
      style={{
        display: "flex",
        width: "100%",
        height: "100%",
        alignItems: "center",
        justifyContent: "center",
        color: "#ffffff",
        fontSize: 120,
        fontWeight: 700,
      }}
    >
      {t.toFixed(1)} s
    </div>
  );
}

Used in: Kinetic type · Data story · the walkthrough · Brand spot in any theme · Stats with handles

Props ​

proptypedefaultrequireddescription
idstringyesThe element's name: unique in the file, and what anchors, ducking and the editor refer to it by.
startnumber (0..∞)Seconds from the start of the video. Free-layout tracks only; on a sequence track the element follows the one before it.
anchor"start" | stringOverlays: start relative to another element's start, or to its end with id.end.
atstringWith anchor: a word, shot or silence of the anchor's source (word:14655); the start is where the anchor plays it, plus offset.
offsetnumberSeconds added to the start that anchor and at give; negative starts earlier.
durationnumber (> 0) | "fill" | "source" | { match } |How long it plays: seconds; "source" for the whole trimmed source; "fill" to run to the end of the composition; { match: id } for as long as another element; { until: id } to end when another element ends.
enterHow it comes in: a fade, slide, scale or wipe over its first seconds, with an easing.
exitHow it goes out, over its last seconds, as enter.
transformMoves, scales, turns and fades the whole layer, as on any element; the editor's handles write it.
blend"normal" | "multiply" | "screen" | "overlay" | "darken" | … 13 moreHow the layer mixes with what is under it, as CSS mix-blend-mode does.
groundbooleanThe layer is a ground that other things sit on: a wall behind a game, a scrim that darkens footage under a title. The layout check then treats it like a background: it is not held to the safe zone and is not said to cover the captions.

Timed, visual, transformable. Children: effect, keyframe. All elements

MIT licensed.