Interactive Features Demo
This page imports the actual components shipped in
src/components/interactive/. Edit the examples below to preview the
experience visitors can receive inside a Setu documentation or learning page.
HTML and CSS playground
Section titled “HTML and CSS playground”The Astro playground renders immediately and keeps the HTML and CSS editors connected to a sandboxed live preview.
Connect it in another .mdx page:
import Playground from "../../../../components/interactive/Playground.astro";
<Playground initialHtml={`<h2>Hello from Setu</h2>`} initialCss={`h2 { color: #818cf8; }`}/>Executable code playground
Section titled “Executable code playground”The React code playground adds a larger editor, live output, console capture, copying, downloading, layout controls, and fullscreen editing.
<main style="font-family:system-ui;padding:2rem">
<h1>Setu executable example</h1>
<button onclick="console.log('Setu example executed')">
Run interaction
</button>
</main>Connect it with a client directive so Astro hydrates the React component:
import { CodePlayground } from "../../../../components/interactive/CodePlayground";
<CodePlayground client:visible language="html" title="example.html" code={`<button onclick="console.log('Executed')">Run</button>`}/>Knowledge-check quiz
Section titled “Knowledge-check quiz”The quiz tracks answers, explains the result, calculates a score, and supports retrying the complete question set.
Why does the Quiz component use client:visible?
Connect a quiz using the same structure:
import { Quiz } from "../../../../components/interactive/Quiz";
<Quiz client:visible title="Quick Check" questions={[ { question: "Which file format supports component imports?", options: ["MDX", "Plain text", "JSON only"], answer: 0, explanation: "MDX combines Markdown content with component imports.", }, ]}/>How the connection works
Section titled “How the connection works”- The
.mdxpage imports a component fromsrc/components/interactive/. - Astro components such as
Playgroundrender directly. - React components such as
QuizandCodePlaygrounduse aclient:*directive for browser interaction. astro.config.mjsloads the built-in interactive feature styles.- Setu’s AI text route removes interface-only JSX and preserves useful written explanation and playground source.
Use this page as the working reference when connecting interactive components inside another MDX document.