npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

markdown-input-display

v1.1.22

Published

A markdown input and preview component for React/Next.js

Readme

📦 markdown-input-display

A lightweight and customizable React/Next.js Markdown editor and preview component — zero dependencies, full flexibility, and blazing-fast rendering.

npm npm bundle size react nextjs license issues pull requests contributors


✨ Overview

markdown-input-display is a plug-and-play Markdown input with live preview, designed specifically for React and Next.js environments. It includes a set of composable components, a custom hook for Markdown-to-HTML conversion, and full styling and icon override capabilities.


🚀 Features

  • ⚛️ Built with plain React — no external dependencies
  • 🖊️ Editable Markdown input with toolbar shortcuts
  • ⚡ Real-time preview mode
  • 🧩 Highly customizable via props and styles
  • 🧠 Easy-to-use useMarkdown hook for conversion
  • 🧰 Pluggable icons (SVGs)
  • 🎨 Flexible styling with full control over internal elements
  • 💼 Ideal for web apps, documentation tools, blogs, note editors, etc.

📦 Installation

npm install markdown-input-display

or

yarn add markdown-input-display

📁 Components & API

1️⃣ MarkdownInput

The Markdown input editor with customizable toolbar and style.

Props:

| Prop | Type | Description | | ---------------- | ------------------------------------- | ---------------------------------------- | | md | string | Markdown input string | | setMd | Dispatch<SetStateAction<string>> | Function to update md | | showPreview | boolean | Toggle for showing preview | | setShowPreview | Dispatch<SetStateAction<boolean>> | Function to toggle preview state | | svgIcons | Record<string, JSX.Element> | Custom SVG icons for the toolbar buttons | | style | Record<string, React.CSSProperties> | Custom styles for editor and toolbar |


2️⃣ MarkdownPreview

Renders the converted HTML content in a preview pane.

Props:

| Prop | Type | Description | | --------- | ------------------------------------- | ------------------------------------------- | | md | string | HTML string to preview (from useMarkdown) | | onClose | () => void | Function to close the preview | | styles | Record<string, React.CSSProperties> | Custom styles for Preview |


3️⃣ useMarkdown

A simple hook to convert a marked Markdown string into HTML.

Usage:

const html = useMarkdown(markdown);

Parameters:

| Param | Type | Description | | ----- | -------- | -------------------------- | | md | string | Markdown string to convert |

Returns:

| Return | Type | Description | | ------ | -------- | ----------------------- | | html | string | HTML output as a string |


🎨 Style Customization

You can override styles using the style prop.

const customStyle = {
  wrapper: { backgroundColor: "#f9f9f9" },
  editor: { border: "1px solid #ddd" },
  toolbar: { background: "#fff" },
  toolbarButtons: { gap: "10px" },
  toolbarBtn: { color: "#555" },
  input: { padding: "10px" },
  preview: { padding: "20px" },
  closeBtn: { backgroundColor: "red", color: "#fff" },
};

Available Style Keys

{
  wrapper,
  editor,
  toolbar,
  toolbarButtons,
  toolbarBtn,
  toolbarBtnHover,
  input,
  preview,
  closeBtn,
  output,
}

🧩 SVG Customization

Pass your own icon set to replace the default toolbar icons.

const icons = {
  h1: {
    icon: () => (
      <svg width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
        <path d="M7.648 13V3H6.3v4.234H1.348V3H0v10h1.348V8.421H6.3V13zM14 13V3h-1.333l-2.381 1.766V6.12L12.6 4.443h.066V13z" />
      </svg>
    ),
  },
  b,
  i,
  h2,
  h3,
  h4,
  h5,
  h6,
  code,
  highlight,
  braces,
  link,
  image,
  q,
  hr,
  ul,
  ol,
  preview,
};

Each key should map to an object with an icon function that returns a JSX SVG.


✅ Supported Markdown

  • Headings: # through ######
  • Bold: **text**
  • Italics: *text*
  • Code: `inline` and code blocks
  • Blockquotes: > text
  • Links: [title](https://example.com)
  • Images: ![alt](image.jpg)
  • Lists: - item, 1. item
  • Custom: ===highlight===<mark>highlight</mark>

🔧 Example Usage

import { useState } from "react";
import { MarkdownInput, MarkdownPreview, useMarkdown } from "markdown-input-display";

export default function App() {
  const [md, setMd] = useState("# Hello Markdown!");
  const [showPreview, setShowPreview] = useState(false);
  const html = useMarkdown(md);

  return (
    <div>
      <MarkdownInput
        md={md}
        setMd={setMd}
        showPreview={showPreview}
        setShowPreview={setShowPreview}
        svgIcons={/* optional custom icons */}
        style={/* optional custom styles */}
      />

      {showPreview && (
        <MarkdownPreview
          md={html}
          onClose={() => setShowPreview(false)}
          styles={/* optional custom styles */}
        />
      )}
    </div>
  );
}

🔭 Roadmap

  • ✅ Live Preview Toggle
  • 🔄 Efficient internal state handling
  • ✍️ More Markdown marker support (tables, checkboxes, etc.)
  • 💻 Improved editing experience (drag-drop, file upload)
  • 🧪 Tests and CI/CD pipeline
  • 📚 Storybook-based documentation

🤝 Contributing

Contributions, issues, and feature requests are welcome!

  1. Fork the project
  2. Create your feature branch (git checkout -b feat/AmazingFeature)
  3. Commit your changes (git commit -m 'feat: Add amazing feature')
  4. Push to the branch (git push origin feat/AmazingFeature)
  5. Open a Pull Request

You can also suggest improvements by opening an issue.


👥 Contributors

Thanks to these amazing people for helping grow the project:

Special thanks to ChatGPT for readme design and documentation assistance! ✨


📄 License

This project is licensed under the MIT License — free to use and modify in personal or commercial projects.


🌐 Links