Simple Marp preview example

HTML

<div id="container">
  <textarea id="md" placeholder="Input your Marp Markdown here."></textarea>
  <div id="render"></div>
</div>

CSS

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

*, *::before, *::after {
  box-sizing: border-box;
}

#container {
  display: flex;
  width: 100%;
  height: 100%;
}

#md {
  display: block;
  resize: none;
  flex: 0 0 50%;
  padding: 16px;
  font-size: 20px;
}

#render {
  flex: 0 0 50%;
  padding: 16px;
  overflow: auto;
}

.marpit {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

[data-marpit-svg] {
  box-shadow: 0 2px 8px #8888;
}

JavaScript

import { Marp } from 'https://esm.sh/@marp-team/marp-core?bundle'
import browser from 'https://esm.sh/@marp-team/marp-core/browser?bundle'

const md = document.getElementById('md')
const render = document.getElementById('render')

const marp = new Marp({ script: false })

const renderMarp = () => {
  const { html, css } = marp.render(md.value)
  render.innerHTML = `${html}<style>${css}</style>`

  browser(render) // Post-process for browser to apply auto scaling
}

md.addEventListener('input', renderMarp)
renderMarp() // Initial rendering