Componenteditors1.35 KB gzipZero dependencies

Markdown Editor

Markdown write/preview tabs with built-in renderer.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add markdown-editor

Or install the full npm package:

npm install bigbullui

Usage

tsx3 lines
import { MarkdownEditor } from "@/components/ui/markdown-editor"; <MarkdownEditor />

Source code

markdown-editor.tsx + 1 helper

Zero 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 />
PropTypeDescription
valuestringControlled value.
defaultValuestringInitial value when uncontrolled.
onValueChange(value: string) => voidCallback invoked on value change.