Importing plugins with @plugin, writing plugin elements in Chalk, combining with parameters and animations
Plugins are first-class Chalk elements. Once imported, a plugin element uses exactly the same syntax as any built-in element and can be combined with parameter sliders, cue animations, and other detail-panel elements.
Declare the plugin at the top of your Chalk file with the @plugin directive:
The src attribute is the plugin's registry URL. The element name is derived from the last path segment of the URL — here, particle-sim. You can then use particle-sim anywhere in the file as an element.
@plugin directives must appear before any scene content, immediately after the document header *(...).
You can import multiple plugins in one file:
Plugin element attributes follow the same Chalk syntax as built-in elements. Use semicolons to separate attributes inline, or newlines in a multi-line block:
Attribute types follow what the manifest declares:
number — numeric literal: gravity: 2.5string — bare value: label: Click meboolean — true or false: loop: truedimensions — tuple: size: (600, 400)colour — colour name: colour: tealThe Chalk parser validates all attributes against the manifest schema and reports errors inline in the editor.
Plugin elements support both a body block {} and a detail block []. These are semantic categories — the same distinction as anywhere else in Chalk. Body is the primary content; detail is the complementary or supporting content. A timeline plugin might use body for the date markers and detail for each date's image and explanation.
Both blocks are passed to the plugin at load time as structured data — InitContext.body and InitContext.detail respectively. The plugin decides how to render them.
The child element types allowed in body and detail are declared in the manifest under chalk.childElements. Elements not in the whitelist are rejected by the Chalk parser. Other plugins can be referenced in the whitelist by their registry URL — see Manifest Reference for the full schema.
Body content also contributes to the element's content hash, which is the key used for interaction storage.
Plugin elements go in the detail panel [] of a scene, the same position as diagram{} and parameter{} elements:
Number attributes can reference a parameter{} variable. When the educator places a parameter{} in the same detail panel and the student moves the slider, the runtime resolves the new value and sends it to the plugin.
Parameter variable names must be single lowercase letters — the same constraint that applies to all Chalk parameter variables. The plugin receives the resolved numeric value, not the variable name.
Plugin elements support cue{} wrapping. The cue fades the plugin frame in or out at the specified time:
The cue fade is applied to the plugin frame as a CSS transition — the plugin does not need to do anything special to support it. Additionally, the SDK delivers the full animation timeline state to your plugin (elapsed time, pause status, cut index), so your rendering can synchronise with the cue timing from inside. See SDK: Animation for details.
cue.draw and cue.morph are not supported for plugin elements. cue.draw is specific to SVG path drawing. cue.morph requires geometry compatibility between same-type elements. Use cue{} for fade-based reveal of plugin elements.
In step-through scenes (where the student presses a forward arrow to advance through cuts), the SDK delivers the current cut index to your plugin. The educator's Chalk controls how many cuts there are; the plugin uses the index to choose what to display:
In this example, the plugin receives cutIndex: 0, cutIndex: 1, and cutIndex: 2 as the student steps forward. The plugin's animation.onState handler can switch internal state accordingly.
By default, importing a plugin URL loads its latest approved version. To pin to a specific version:
Pinning is recommended for internotes that should remain stable over time, such as published courses or archived lesson materials.
During development, reference your local manifest by file path. The dev CLI prints the exact path to use when you run npm run dev:
File path plugin sources only work in the editor while the dev CLI is running, and only for your own account. Replace with the registry URL before sharing your work.