Use docspress/code-playground for a small HTML, CSS, and JavaScript example readers should edit and run in the page. It combines source editors, a sandboxed result, and bounded console output.
When to use it
Choose Live Code Playground when interaction is essential to the lesson. Use Colorful Code when readers only need to study or copy source. Keep multi-file applications and build-tool examples in a real repository or hosted development environment.
Edit the block
Provide self-contained HTML, CSS, and JavaScript. Set a preview height from 180–720 pixels, decide whether the example runs on load, and show the console only when its output teaches something. Leave network access disabled unless the example genuinely depends on a public resource.
Attributes
Live Code Playground attributes
docspress/code-playground.-
titlestring -
Plain-text playground heading.
-
htmlstring -
HTML placed in the sandboxed document body.
-
cssstring -
CSS placed in an inline style element.
-
javascriptstring -
JavaScript evaluated inside the sandbox.
-
heightnumber -
Preview height in pixels, clamped to 180–720.
-
autoRunboolean -
Runs the authored source when the page loads.
-
showConsoleboolean -
Shows relayed console messages and errors.
-
allowNetworkboolean -
Relaxes the sandbox document policy to allow network requests.
No fields match this filter.
The block supports wide alignment in addition to the shared design controls.
Creative examples
Interactive publish button
Theme-token mixer
Accessible disclosure lab
Sandbox and output
The result iframe uses sandbox="allow-scripts" without same-origin access and sends no referrer. A Content Security Policy blocks network access unless the author enables allowNetwork. Run rebuilds the sandbox, Reset restores the authored source, and console calls and errors are relayed only from the active result. Console history is bounded to 100 lines.
Keep examples focused on one behavior, supply visible labels and keyboard interaction in the demo itself, and verify both the initial result and the Reset state.