Composition basics
At its core, a composition is:- Configuration: Duration, FPS, dimensions, and other metadata
- Content: HTML, CSS, and JavaScript that renders the visual output
- Timeline: Optional tracks and clips for multi-layer compositions
Creating a composition
packages/core/src/types.ts:11 for the full HeliosConfig interface.
Configuration options
Required properties
- duration
- fps
Duration of the composition in seconds (not frames).
- Must be non-negative
- Can be changed dynamically with
setDuration() - Frames are calculated as
duration * fps
Optional properties
Input props and schemas
Compositions can accept user-defined data throughinputProps. This is useful for creating reusable templates.
Basic input props
Schema validation
Define a schema to validate and provide defaults for input props:setInputProps().
See packages/core/src/schema.ts for the full validation API.
Timeline and clips
Helios supports multi-track timelines for complex compositions.Timeline structure
packages/core/src/types.ts:31 for timeline type definitions.
Active clip tracking
Helios automatically computes which clips are active at the current time:Helios.ts:508:
Composition file structure
For server-side rendering, compositions are typically standalone HTML files:The
bindToDocumentTimeline() call is critical for server-side rendering. It tells Helios to read from document.timeline.currentTime (or __HELIOS_VIRTUAL_TIME__ in headless mode) instead of driving its own playback loop.Helios.ts:1085 for the timeline binding implementation.
Captions and markers
Captions
Helios supports SRT and WebVTT caption formats:packages/core/src/captions.ts for parsing implementation.
Markers
Markers are named points on the timeline:Playback range
Render or preview only a portion of the composition:play()starts at the range start- Playback stops at the range end
- Looping wraps within the range
Composition patterns
React composition
Canvas composition
Multi-scene composition
Best practices
Use absolute positioning
Preload assets
Use CSS animations for simple motion
Bind to document timeline for rendering
Without
bindToDocumentTimeline(), the renderer won’t be able to control the composition’s timeline via CDP virtual time.Next steps
- Explore timeline control for playback APIs
- Learn about animations for motion control
- Understand drivers for custom time sources