vidmake v0.2.1
Download

Docs/LayersPage 19 / 45

Components

Reuse a composition as a layer with use and ref, pass it props, and understand its default size, duration and clipping — with a reusable lower third as the worked example.

View .md Ask Claude Ask ChatGPT

Any composition in a project can be drawn inside another one with a use layer. Give the inner composition props with defaults, reference them as {{name}}, and every use can pass different values. This is vidmake's version of a React component (or Remotion's nested <Composition>).

json
{ "id": "ada", "type": "use", "ref": "lowerThird", "start": "2s",  "props": { "name": "Ada Lovelace", "role": "Analyst" } }
fielddefaultnotes
refrequiredThe id of a composition in the same project.
props{}Values for the referenced composition's {{...}} placeholders. Missing ones use its defaults.
width, heightthe referenced composition's sizeThe box the component is drawn and clipped in.
durationthe referenced composition's duration
cliptrueContent outside the box is hidden; set false to let it spill out.

All common fields work on a use layer, exactly as on a group: position, anchor, rotation, scale, opacity, shadow, filters, masks and enter/exit presets.

#A reusable lower third

The component is an ordinary composition sized to its content (here 640×140), with its own props defaults. The main composition places two instances in the bottom-left corner, each with its own name, role and accent color:

00:00.0 · f 000
One lowerThird composition, used twice with different propsDownload

What to notice in the JSON:

  • lowerThird declares "props": { "name": "Name", "role": "Role", "color": "#161412" }. Those are the defaults, used when a use layer leaves a prop out (and when you render the component alone).
  • {{color}} is the whole string of fill, so it is replaced by the raw prop value; a paint object or a number would work as well. {{name}} inside a longer string is spliced in as text. See Props for the exact rules.
  • The use layers are anchored bottom-left, so the component's box is placed by its corner, like any layer.
  • The component's own presets (wipeRight in, fadeDown out) play at its start and end, so each instance animates in and out without the main composition knowing how.

#Size, time and clipping

Size. A use layer's box defaults to the referenced composition's width×height. The children keep the coordinates they have in their own composition. Setting width/height on the use layer changes the box it is clipped to (and what percentages inside resolve against), but does not scale the content. To draw a component bigger or smaller, use scale.

Duration. A use layer lasts as long as the referenced composition ("duration": "2.2s" for the lower third), so it has a fixed length that works in series and in "duration": "auto". Set duration on the use layer to cut it shorter. Times inside follow the component's clock: its layers start at the use layer's start. If the component has a different fps, its timing is converted and validate warns, since expressions that count frames may behave differently.

Clipping. Components are clipped to their box by default, like a picture-in-picture. Make the component composition large enough for its shadows and animations (a slide* exit leaves the box entirely, a fadeDown moves 32 px, or 0.3em on text), or set "clip": false on the use layer.

vidmake timeline lists each instance with its children, which is a quick way to check when each one plays:

vidmake timeline components-lower-third.json
$ vidmake timeline components-lower-third.json
Composition `main` — 1280x720 @ 30fps, 150 frames (5.00s)

ID        TYPE         START      END      DUR  DETAILS
ada       use          0.20s    2.40s    2.20s  "4 children"
  plate   rect         0.20s    2.40s    2.20s  enter:wipeRight exit:fadeDown
  accent  rect         0.20s    2.40s    2.20s  enter:fade exit:fade
  name    text         0.40s    2.40s    2.00s  enter:fadeRight exit:fade "Ada Lovelace"
  role    text         0.55s    2.40s    1.85s  enter:fadeRight exit:fade "Analyst, Analytical Engine"
grace     use          2.60s    4.80s    2.20s  "4 children"
  plate   rect         2.60s    4.80s    2.20s  enter:wipeRight exit:fadeDown
  accent  rect         2.60s    4.80s    2.20s  enter:fade exit:fade
  name    text         2.80s    4.80s    2.00s  enter:fadeRight exit:fade "Grace Hopper"
  role    text         2.95s    4.80s    1.85s  enter:fadeRight exit:fade "Compiler pioneer"

          |0s          1s          2s          3s          4s          |
ada       |··███████████████████████████·······························|
  plate   |··███████████████████████████·······························|
  accent  |··███████████████████████████·······························|
  name    |····█████████████████████████·······························|
  role    |······███████████████████████·······························|
grace     |·······························███████████████████████████··|
  plate   |·······························███████████████████████████··|
  accent  |·······························███████████████████████████··|
  name    |·································█████████████████████████··|
  role    |···································███████████████████████··|

#Props in action

Props can be numbers and can feed expressions, because placeholders are filled in before the project is compiled. This stat component counts up to its value prop; three instances sit in a row layout, which measures each one by its box:

00:00.0 · f 000
A stat component used three times in a row layout, each with its own propsDownload
inside the stat componentjson
"text": "${fmt(round({{value}} * easeOutCubic(clamp(t / 1.5, 0, 1))))}"

With "value": 1280, that becomes ${fmt(round(1280 * ...))}.

Props flow one level at a time. A use layer's props can themselves contain the outer composition's placeholders, e.g. "props": { "color": "{{accent}}" } passes the main composition's accent prop down. A {{name}} with no value anywhere is reported by validate as an unknown prop; extra props that the component never uses are ignored.

#Working on a component alone

A component is a normal composition, so every command can target it with --comp:

bash
vidmake storyboard project.json --comp lowerThird -o lt.png -n 6vidmake still project.json --comp lowerThird -t 1s -o lt.png --props '{"name":"Grace Hopper"}'vidmake render project.json --comp lowerThird -o lower-third.mov   # transparent ProRes 4444

vidmake list project.json shows every composition with its size, duration and props. Without --comp, commands use the first composition, so keep the main one first in the compositions array.

Tip

Size a component's composition to its content, not to the full frame: the box then means something (anchors, layouts and inspect bounding boxes all use it), and the transparent margins don't hide other layers through clipping.

#Rules and limits

  • ref must name a composition in the same file. A use can reference a composition that itself contains use layers, up to 12 levels deep; a composition that (directly or indirectly) uses itself is an error.
  • Instances share the component's layer ids: both lower thirds have a name layer, and inspect shows each nested under its own use id. Editing commands (vidmake set name.fontSize 44) change the component itself, and with it every instance; keep ids unique across the file so such paths are unambiguous (they resolve to the first match).
  • A component's background is ignored when it is used as a layer. Draw a background rect inside it if it needs one.