
Security News
Ruby's Bundler 4.0.18 Extends Cooldown to bundle lock and bundle cache
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.
@markdown-ui/react
Advanced tools
React renderer for markdown-ui widgets. This package provides React components that work with the markdown-ui widget system.
See markdown-ui Github.
npm install @markdown-ui/react @markdown-ui/marked-ext @markdown-ui/mdui-lang
import React from 'react';
import { MarkdownUI } from '@markdown-ui/react';
import '@markdown-ui/react/widgets.css'; // Optional styling
import { marked } from 'marked';
import { markedUiExtension } from '@markdown-ui/marked-ext';
// Configure marked with the UI extension
marked.use(markedUiExtension);
const App = () => {
const markdown = `
# My Form
\`\`\`markdown-ui-widget
{
"type": "text-input",
"id": "name",
"label": "Your Name",
"placeholder": "Enter your name"
}
\`\`\`
Or use the more concise DSL syntax:
\`\`\`markdown-ui-widget
text-input name "Your Name" "Enter your name"
\`\`\`
`;
const html = marked(markdown);
const handleWidgetEvent = (data: any) => {
console.log('Widget event:', data);
};
return (
<MarkdownUI
html={html}
onWidgetEvent={handleWidgetEvent}
/>
);
};
All widgets from the Svelte implementation are available:
The @markdown-ui/marked-ext extension now supports both JSON and DSL syntax in markdown-ui-widget code blocks. The DSL is 60-70% more concise than JSON:
JSON:
{"type": "textInput", "id": "name", "label": "Name", "placeholder": "Enter name"}
DSL:
text-input name "Name" "Enter name"
Both syntaxes produce identical widget output. The extension automatically detects the format.
\`\`\`markdown-ui-widget
{
"type": "text-input",
"id": "name",
"label": "Name",
"placeholder": "Enter your name",
"default": "John Doe"
}
\`\`\`
Or with DSL:
\`\`\`markdown-ui-widget
text-input name "Name" "Enter your name" "John Doe"
\`\`\`
\`\`\`markdown-ui-widget
{
"type": "button-group",
"id": "choice",
"label": "Choose an option",
"choices": ["Option A", "Option B", "Option C"],
"default": "Option A"
}
\`\`\`
Or with DSL:
\`\`\`markdown-ui-widget
button-group choice [OptionA OptionB OptionC] OptionA
\`\`\`
\`\`\`markdown-ui-widget
{
"type": "slider",
"id": "value",
"label": "Value",
"min": 0,
"max": 100,
"step": 1,
"default": 50
}
\`\`\`
Or with DSL:
\`\`\`markdown-ui-widget
slider value 0 100 1 50
\`\`\`
\`\`\`markdown-ui-widget
{
"type": "form",
"submitLabel": "Submit Form",
"fields": [
{
"type": "text-input",
"id": "name",
"label": "Name",
"placeholder": "Your name"
},
{
"type": "select",
"id": "country",
"label": "Country",
"choices": ["USA", "Canada", "UK"]
}
]
}
\`\`\`
Import the CSS file for default styling:
import '@markdown-ui/react/widgets.css';
You can also customize the styling by overriding the CSS classes:
.widget - Base widget container.widget-form - Form container.widget-button-group - Button group container.widget-button - Text input container.selector - Select dropdown container.selector-multi - Multi-select container.widget-slider - Slider containerThe onWidgetEvent callback receives data when widget values change:
const handleWidgetEvent = (data: { id: string, value: any }) => {
console.log(`Widget ${data.id} changed to:`, data.value);
};
This package includes full TypeScript definitions. All components are typed and provide IntelliSense support.
Due to the use of Web Components and browser APIs, this library requires client-side rendering. Use dynamic imports with SSR disabled:
import dynamic from 'next/dynamic';
const MarkdownUI = dynamic(() => import('@markdown-ui/react').then(mod => ({ default: mod.MarkdownUI })), {
ssr: false
});
export default function Page() {
const handleWidgetEvent = (data: any) => {
console.log('Widget event:', data);
};
return (
<MarkdownUI
html={yourProcessedHtml}
onWidgetEvent={handleWidgetEvent}
/>
);
}
FAQs
React renderer for markdown-ui
The npm package @markdown-ui/react receives a total of 21 weekly downloads. As such, @markdown-ui/react popularity was classified as not popular.
We found that @markdown-ui/react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.

Security News
During a UK cyber test, a Mythos 5 agent used sockpuppets, social engineering, and prompt injection to try to get a maintainer to merge malware.

Company News
Socket is now in the AWS Security Hub Extended plan. Adopt it through AWS, apply committed spend, and block malicious open source packages.