HxMarkdown #

Renders Markdown content as HTML using Bootstrap typography.

Basic usage #

Pass a Markdown string to the Content parameter.

Hello, Markdown! This is a paragraph with italic and inline code.

<HxMarkdown Content="@_markdown" />

@code {
	private string _markdown = """
		**Hello, Markdown!** This is a paragraph with *italic* and `inline code`.
		""";
}

Rich content #

Supports headings, lists, blockquotes, code blocks, tables, and inline formatting (bold, italic, strikethrough, inline code, links, images).

Heading 1

Heading 2

A paragraph with bold, italic, strikethrough, and code.

This is a blockquote.

  • First item
  • Second item
  • Third item
  1. Ordered one
  2. Ordered two
  3. Ordered three

Visit Havit Blazor.

Code blocks #

Fenced code blocks are rendered inside <pre><code> with an optional language-* class.

public class HelloWorld
{
    public static void Main()
    {
        Console.WriteLine("Hello, World!");
    }
}

Inline code: var x = 42;

Tables #

Markdown tables are rendered with a configurable CSS class (default table for Bootstrap styling).

NameRoleStatus
AliceDeveloperActive
BobDesignerActive
CarolManagerAway

HTML sanitization #

By default, HTML tags in the input are escaped. Set SanitizeHtml="false" to allow raw HTML pass-through (use only with trusted content).

Default (sanitized):

This has <strong>raw HTML bold</strong> and a <span style="color: red;">red span</span>.

With SanitizeHtml="false":

This has raw HTML bold and a red span.

Custom CSS classes #

Override the Bootstrap CSS classes applied to tables, blockquotes, and images via parameters or HxMarkdown.Defaults.

Header 1Header 2
Cell ACell B
Cell CCell D

A styled blockquote with custom CSS.

Wrapper element #

By default, no wrapper <div> is rendered. A wrapper is automatically added when you set CssClass or AdditionalAttributes.

Without wrapper (default):

A simple paragraph rendered from Markdown.

With wrapper (CssClass set):

A simple paragraph rendered from Markdown.

API #

Parameters #

Name Type Description
ContentREQUIRED string Markdown text to render as HTML.
AdditionalAttributes Dictionary<string, object> Additional attributes to be splatted onto the wrapper <div> element. When set, the output is wrapped in a <div>.
BlockquoteCssClass string CSS class for <blockquote> elements rendered from markdown blockquotes. Default is "blockquote" (Bootstrap blockquote).
CssClass string Any additional CSS class to apply to the wrapper element. When set (or when AdditionalAttributes is used), the output is wrapped in a <div>.
ImageCssClass string CSS class for <img> elements rendered from markdown images. Default is "img-fluid" (Bootstrap responsive image).
SanitizeHtml bool? When true (default), HTML tags in the input are escaped. When false, raw HTML in the input passes through to the output (use only with trusted content).
Settings MarkdownSettings Set of settings to be applied to the component instance (overrides Defaults, overridden by individual parameters).
TableCssClass string CSS class for <table> elements rendered from markdown tables. Default is "table" (Bootstrap table).

Static properties #

Property Type Description
Defaults MarkdownSettings Application-wide defaults for HxMarkdown and derived components.
An unhandled error has occurred. Reload 🗙