Rich Text Editor
Edit a short description with bold and italic text and preview the submitted result.
HTML
<form class="rlw-editor" data-rlw-editor hx-post="/demo/workspace/preview" hx-target="find output">
<div class="rlw-editor-tools" role="group" aria-label="Text formatting" hidden>
<button type="button" data-format="bold" aria-label="Bold" aria-pressed="false"><b>B</b></button>
<button type="button" data-format="italic" aria-label="Italic" aria-pressed="false"><i>I</i></button>
</div>
<textarea class="rl-input" name="body" aria-label="Product description" maxlength="4000">A lamp for the quiet hours.</textarea>
<button class="rl-button rl-button-sm rl-button-secondary" type="submit">Preview description</button>
<output class="rlw-rich-preview" aria-live="polite"></output>
</form>HTTP exchange
Use the preview to see the request and the HTML your server returns.The server receives text runs with bold and italic flags and escapes their contents. Pasted content is plain text.
Use in your app
Copy these tags into your page head once. Serve the files at the paths shown, then add the example’s template to your page.
Page assets
<link rel="stylesheet" href="/mero.css">
<link rel="stylesheet" href="/mero-workspace.css">
<script defer src="/vendor/htmx.min.js"></script>
<script defer src="/mero.js"></script>
<script defer src="/mero-workspace.js"></script>Point the HTMX attributes at your own HTML endpoints. Use the live preview’s HTTP exchange to inspect the request and response.
Download library and examples ↓