AiSandbox

Sandbox

Runnable code sandbox preview.

Model picker
const models = ['gpt-4o', 'claude-sonnet', 'gemini-pro']
const picked = models[Math.floor(Math.random() * models.length)]
console.log('Selected:', picked)

Output

Usage

<AiSandbox
  :code="snippet"
  language="javascript"
  title="Model picker"
  :auto-run="true"
>
  <template #header="{ title, run, isRunning }">
  </template>
  <template #editor="{ code, language }">
  </template>
  <template #output="{ iframeHtml, frameVersion, error }">
  </template>
</AiSandbox>

Props

Prop Type Default Description
code*string
languagestring'html'html, javascript, or js
templatestringCustom iframe HTML; use {{code}} as placeholder
titlestringAccessible label and header title
autoRunbooleanfalseEmit run on mount (refreshes JS iframe)

Slots

  • default
  • header
  • title
  • editor
  • output