Refactored JSX elements from lowercase to PascalCase, including `<scene>` to `<Scene>`, `<text>` to `<Text>`, and others, to improve consistency and clarity in the codebase. Updated related documentation to reflect these changes, ensuring that the usage of JSX elements aligns with the new naming conventions. This update enhances the overall readability and usability of the JSX API.
4.1 KiB
4.1 KiB
Element reference
PascalCase composition elements map 1:1 onto internal node types (lowercase tags are DOM vocabulary, valid only inside <Html> content):
| Element | Internal node | Notes |
|---|---|---|
<Scene> |
Geometry with Scene tag | Clips its children to width×height. Document root only. |
<Group> |
Geometry with Group tag | Container with a transform; auto-fits its size from its children. Takes no fill or explicit size. |
<Rect> |
Geometry with Solid paint | A filled rectangle; takes only paint children. |
<Video> |
Geometry with Video paint | src resolves to a video asset. |
<Image> |
Geometry with Image paint | src resolves to an image asset. |
<Audio> |
Geometry with Audio component and a hidden Waveform paint | No visual output; carries volume. |
<Text> |
Geometry with Text component | Children become editable glyphs. |
<Sequence> |
Sequential group | Track container for back-to-back clips; positions are explicit. |
<Captions> |
Caption node | Transcribes the enclosing scene's audio. |
<SolidPaint> |
Solid paint | Paint child. |
<LinearGradientPaint> / <RadialGradientPaint> |
Gradient paint | Paint child; takes <ColorStop> children. |
<ColorStop> |
Gradient color stop | Valid only inside gradient paints. |
<Html> (long form <HtmlPaint>) |
Html paint | Paint child whose children are real, reactive HTML drawn by the browser (html-in-canvas, flagged Chromium API). |
<Surface> (long form <SurfacePaint>) |
Surface paint | Paint child whose ref hands you a canvas to draw with any context type (2d, webgl, webgpu); sampled every frame. |
User-defined components are ordinary Solid components; they compose the elements above and carry no runtime cost. Only the elements above produce entities.
Coordinates and sizing
- Coordinates are pixels relative to the parent's box, origin top-left. No percentages, no layout keywords; explicit numbers until the layout engine lands.
- Every element's box defaults to its parent's box:
xandydefault to0,widthandheightdefault to the parent's size (the JSX analog ofposition: absolute; inset: 0). The scene's box is its requiredwidth×height. - How media pixels map into the box is controlled by
objectFit(default"cover"), never by the box itself. A generated asset's placeholder therefore always has a definite size, even before the asset exists.
Common props
All visual elements accept:
| Prop | Type | Default | Meaning |
|---|---|---|---|
key |
string |
none | Stable identity across mounts; required on document roots (see roots.md). |
name |
string |
none | Human-readable node name. |
x, y |
Animatable<number> |
0 |
Position relative to the parent, px. |
width, height |
Animatable<number> |
parent size | Box size, px. |
rotation |
Animatable<number> |
0 |
Rotation in degrees. |
opacity |
Animatable<number> |
1 |
0-1. |
cornerRadius |
Animatable<number> |
0 |
Uniform corner radius, px. |
start, end, sourceIn, sourceOut |
Time |
see timing.md | Temporal placement. |
transition |
TransitionSpec | null |
none | Transition into the next clip; direct children of <Sequence> only (see transitions.md). |
animations |
AnimationSpec[] |
none | Preset in/out animations over the clip's head and tail (see animations.md). |
Animatable props also take a keyframe list; see keyframes.md.
One property table
Common and per-element props share a single property table, exported as PatchProps from @diffusionstudio/jsx. dapi node patch accepts exactly these keys, with the same value requirements, as patch entries on existing nodes; JSX and CLI cannot drift.