Componenteditors1.35 KB gzipZero dependencies
Markdown Editor
Markdown write/preview tabs with built-in renderer.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add markdown-editorOr install the full npm package:
npm install bigbulluiUsage
tsx3 lines
import { MarkdownEditor } from "@/components/ui/markdown-editor"; <MarkdownEditor />Source code
markdown-editor.tsx + 1 helperZero third-party dependencies (2 local files shown in tabs below).
tsxmarkdown-editor.tsx121 lines
"use client"; import * as React from "react";import { cn, isSafeUrl } from "./lib/utils"; export interface MarkdownEditorProps extends React.HTMLAttributes<HTMLDivElement> { value?: string; defaultValue?: string; onValueChange?: (value: string) => void;} /** Markdown write and preview tabs: basic renderer (headings, lists, code, links, bold). */function renderMarkdown(src: string): React.ReactNode { const lines = src.split("\n"); const out: React.ReactNode[] = []; let listItems: string[] = []; let inCode = false; let codeLines: string[] = [];Props
Interactive Prop Playground
Tweak parsed AST props below to generate ready-to-paste JSX.
tsx3 lines
import { MarkdownEditor } from "@/components/ui/markdown-editor"; <MarkdownEditor />| Prop | Type | Description |
|---|---|---|
| value | string | Controlled value. |
| defaultValue | string | Initial value when uncontrolled. |
| onValueChange | (value: string) => void | Callback invoked on value change. |