Interactive Demos
Explore all the features of the <code-playground> component.
Auto Run
The default mode. Edits are debounced and the preview rebuilds automatically after a short delay.
Manual Run
Set run-mode="manual" to require an explicit click of the Run button. Useful for scripts with side effects.
Console Output
The runtime console bridges log, info, warn,
error, and debug from the sandboxed iframe. Filter by level,
search by text, collapse repeated messages, and copy output.
Bottom Preview
Use preview-position="bottom" to stack the preview below the editor instead of beside it.
Dark Mode
Set mode="dark" to force dark theme, or mode="auto" (default) to follow the page.
Add inherit-theme to propagate data-mode and data-theme into the preview iframe.
Persistence
Set the persist attribute to a unique key. The component saves source, active tab,
and split position to localStorage. Edits survive page reloads.
External Sources
Load panels from external files with html-src, css-src,
js-src, and head-src attributes. Great for embedding
exercises sourced from separate files.
CodePen Export
Every playground has a CodePen button in its toolbar. Click it to open the current HTML, CSS, and JS in a new CodePen pen.