Skip to main content

Crate leptos_md

Crate leptos_md 

Source
Expand description

§leptos-md

A simple, signal-free Markdown renderer for Leptos with Tailwind CSS styling.

§Quick Start

use leptos::prelude::*;
use leptos_md::Markdown;

#[component]
fn App() -> impl IntoView {
    view! {
        <Markdown content="# Hello World\n\nThis is **markdown**!" />
    }
}

§Features

  • Dead simple API - <Markdown content=md /> and you’re done
  • Beautiful by default - Tailwind prose styling with dark mode support
  • GitHub Flavored Markdown - Tables, task lists, strikethrough, footnotes
  • Code block themes - Built-in Tailwind themes (GitHub, Monokai, Dark, Light)
  • External highlighter ready - Outputs language-xxx classes for Prism.js, highlight.js
  • SSR ready - Works seamlessly with Leptos server-side rendering

§Customization

Use MarkdownOptions for fine-grained control:

use leptos_md::{Markdown, MarkdownOptions, CodeBlockTheme};

let options = MarkdownOptions::new()
    .with_gfm(true)
    .with_code_theme(CodeBlockTheme::GitHub)
    .with_language_classes(true)
    .with_new_tab_links(true);

view! {
    <Markdown content="# Hello" options=options />
}

Structs§

MarkdownClasses
Tailwind CSS class names for markdown elements
MarkdownOptions
MarkdownProps
Props for the Markdown component.
MarkdownRenderer

Enums§

CodeBlockTheme

Functions§

Markdown
Main component for rendering Markdown content with Tailwind CSS styling
MarkdownStyles
Placeholder component - Tailwind handles all styling
get_code_theme_classes
Get theme-specific classes for code blocks
get_enhanced_prose_classes
Enhanced Tailwind prose configuration for better markdown styling
render_markdown_string
Utility function to render markdown string directly to AnyView with Tailwind styling
render_markdown_with_options
Utility function to render markdown with custom options and Tailwind styling