Core Functions
createPlayground
Creates a LiveCodes playground instance.Signatures
Parameters
The container element or CSS selector where the playground will be rendered.In headless mode, this parameter is optional and can be omitted.
The embed options for configuring the playground.
Returns
A promise that resolves to a
Playground object with methods to interact with the playground.Example
getPlaygroundUrl
Generates a URL to a LiveCodes playground from the provided options.Signature
Parameters
The embed options to encode in the URL.
Returns
The URL of the playground as a string.
Example
EmbedOptions
Configuration options for embedding a playground.Properties
The URL of the LiveCodes app to use. Useful for self-hosted instances or permanent URLs.
URL query parameters that configure the playground. Alternative to using
config.A configuration object or URL to a JSON file containing configuration.Or:
If
true, the playground loads in headless mode (no visible UI).A resource to import from any supported source (GitHub, GitLab, gist, etc.).
Sets how the playground loads:
"lazy": Loads when entering viewport"click": Shows “Click to load” screen"eager": Loads immediately
A starter template to load (e.g.,
"react", "vue", "typescript", "python").See all available templates in the types documentation.If
true, loads the playground in lite mode.The default view for the playground.
Playground Interface
ThePlayground object returned by createPlayground provides methods to interact with the playground.
Config Interface
The configuration object that defines the playground state.ContentConfig
Properties that define the project content:Project title used in the result page and meta tags.
Project description for search and meta tags.
Configuration for the markup editor (HTML, Markdown, etc.).
Configuration for the style editor (CSS, SCSS, etc.).
Configuration for the script editor (JavaScript, TypeScript, etc.).
Array of external stylesheet URLs.
Array of external script URLs.
CSS processors to enable (e.g.,
["tailwindcss", "autoprefixer"]).Custom settings for the project (import maps, types, etc.).
Custom import maps for module resolution.
Custom TypeScript type declarations for better IntelliSense.
Configuration for tests.
AppConfig
Properties that define app behavior:If
true, editors are read-only.If
false, hides the language selector UI.The default view for the playground.
The display mode for the playground.
Configuration for the tools pane.
Result page zoom level.
UserConfig
User preferences and editor settings:Auto-update result page on code change.
Auto-save project on code change.
Delay in milliseconds before auto-update/auto-save.
Auto-format code on save.
App theme.
Code editor to use.
Editor font size.
Number of spaces per indentation level.
Code Interface
Represents the code in all editors and the result page.Language Type
Supported language names, aliases, and extensions:Next Steps
Methods
Explore all playground methods in detail
Events
Learn about the event system
Types
Browse complete TypeScript types
React Component
Use the React component