Skip to content

Quick start

<script lang="ts">
import { MarkdownEditor, headingsPlugin, listsPlugin, quotePlugin } from '@the-sumeet/sveltedown';
let markdown = $state('# Hello\n\nStart **writing**…');
const plugins = [headingsPlugin(), listsPlugin(), quotePlugin()];
</script>
<MarkdownEditor bind:markdown {plugins} placeholder="Start writing…" />

Without plugins, the editor supports paragraphs and inline formatting: bold, italic, underline, inline code, strikethrough, highlight, and super and subscript. Every other construct comes from a plugin. Markdown that uses a construct whose plugin isn’t enabled can’t be loaded: the editor reports it through onerror.

bind:markdown keeps your state and the editor in sync both ways. You can also listen to changes:

<MarkdownEditor
markdown={initial}
onchange={(markdown, initialMarkdownNormalize) => save(markdown)}
/>

initialMarkdownNormalize is true when the change only normalizes the initial markdown, for example - bullets that the editor writes as * (see toMarkdownOptions).

Bind the component to call its methods:

<script lang="ts">
import { MarkdownEditor, type MarkdownEditorMethods } from '@the-sumeet/sveltedown';
let editor: MarkdownEditorMethods;
</script>
<MarkdownEditor bind:this={editor} markdown="Hello" />
<button onclick={() => editor.insertMarkdown('**inserted**')}>Insert</button>

See the props and methods reference for the full list.

The home page demo enables every plugin with the KitchenSinkToolbar. The guides cover each feature with a focused demo.