Component libraryMarkdown editor
Markdown editor
ProEdit controlled Markdown source and inspect a safe local preview.
npx shadcn@latest add @tidal-pro/markdown-editorInstallation
Pro source is gated. Configure the @tidal-pro registry using the agent guide. Create an access key from your account after purchasing.
Terminal
Import components/ui/tidal.css, components/ui/markdown-editor.css, components/ui/textarea.css, components/ui/toolbar.css, then add the component inside a tidal-scope wrapper. Its scoped design tokens keep it independent of your existing CSS.
Usage
Complete example source · Dependency and asset manifest
Loading the complete example…
API & behavior
Required visible label, controlled value:string/onValueChange(value,event), controlled mode ('write'|'preview'|'split') and onModeChange(mode,event). The editor composes TidalToolbar and TidalTextarea. The same successful native textarea remains mounted in every view, preserving exact FormData, required validation, ref and selection; in Preview it is removed from sequential focus and visually concealed until native invalid/focus handling reveals the actual field. textareaProps preserves native name/form/required/placeholder/rows/maxLength/input/change/composition/selection attributes while the editor owns its visible/accessibility label, controlled value, availability and change proposal; textareaRef is supported. Native textarea onChange runs first and prevention suppresses onValueChange. Formatting actions cover bold, italic, level-two heading source, bulleted lists, links and inline/fenced code; they use the textarea's native selection, propose exact controlled source, and restore focus/selection only after synchronous acceptance while the formatting source or body still owns focus. Consumer-directed external focus is preserved. Declined proposals are consumed immediately and cannot steal focus after an unrelated later change. formatButtonProps/refs and modeButtonProps/refs preserve caller-first native handlers while excluding replacement markup, submit/form/value, owned availability and pressed state. disabled blocks editing, mode changes, formatting and preview links; readOnly blocks source edits/formatting while keeping view switching and preview links available. Optional description, error, dir('ltr' default or 'rtl'), localized labels, previewHeadingLevel(2|3|4), native preview region attributes and root div attributes/ref are supported; dir also configures the composed toolbar keyboard direction. Owned markup, content, naming, role and aggregate aria-disabled channels are type-excluded and runtime-stripped. The safe React preview recognizes source headings # through ###, paragraphs, bold, italic, inline/fenced code, ordered/unordered lists, single-line quotes and safe hash/root/http/https/mailto links. Raw HTML is never parsed, unsafe links and unsupported syntax remain plain text, and no Markdown package, code execution, request, clipboard, upload, storage, persistence or publishing behavior is included.
Style with the --t-* CSS variables. Set data-theme="dark" on your tidal-scope wrapper for a dark surface. Motion respects the system’s reduced-motion preference.