Markdown Editor

Textarea Markdown editor with an undo-safe formatting toolbar and shortcuts, list continuation and Tab indenting, a floating selection toolbar, Write/Preview/Split tabs with a gliding indicator, and a built-in safe renderer that outputs React elements, never raw HTML.

Preview

Markdown Editor preview width

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @karaui/markdown-editor
@karaui not found? Add it to components.json
{
  "registries": {
    "@karaui": "https://karaui.kamisama-v0.my.id/r/{name}.json"
  }
}

@karaui is in shadcn's public registry directory, so the latest CLI needs no setup. On an older CLI, merge this into the existing file once and every @karaui/… install resolves.

API Reference

MarkdownPreview

source
string
—
className?
string
—
emptyLabel?
ReactNode
Nothing to preview

MarkdownEditor

value?
string

Controlled Markdown source.

—
defaultValue?
string

Initial source when uncontrolled.

onChange?
((value: string) => void)
—
mode?
"write" | "preview" | "split"

Controlled view mode.

—
defaultMode?
"write" | "preview" | "split"
write
onModeChange?
((mode: MarkdownEditorMode) => void)
—
placeholder?
string
Write in Markdown…
minHeight?
number

Textarea auto-grows between these heights (px), then scrolls.

160
maxHeight?
number
360
selectionToolbar?
boolean

Floating formatting toolbar that appears over a text selection.

true
showFooter?
boolean

Word / character count footer.

true
disabled?
boolean
false
readOnly?
boolean
false
name?
string
—
id?
string
—
label?
string

Accessible name for the textarea.

Markdown editor
className?
string
—
textareaClassName?
string
—
previewClassName?
string
—

Updated