Kotlin Multiplatform Markdown Renderer
... a powerful Kotlin Multiplatform Markdown Renderer for Kotlin Multiplatform projects using Compose Multiplatform
What's included 🚀 •
Setup 🛠️ •
Usage 🛠️ •
License 📓
What's included 🚀
Setup
Using Gradle
Choose the appropriate configuration based on your project type:
Multiplatform
For multiplatform projects, add these dependencies to your build.gradle.kts:
JVM (Desktop)
For JVM-only projects, add this dependency:
dependencies {
implementation("com.mikepenz:multiplatform-markdown-renderer-jvm:${version}")
}
Android
For Android-only projects, add this dependency:
dependencies {
implementation("com.mikepenz:multiplatform-markdown-renderer-android:${version}")
}
[!IMPORTANT]
Since version 0.13.0, the core library does not depend on a Material theme. You must include
either the -m2 or -m3 module to get access to the default styling.
Usage
What's included 🚀
The most basic usage is to simply pass your markdown string to the Markdown composable:
Markdown(
"""
# Hello Markdown
This is a simple markdown example with:
- Bullet points
- **Bold text**
- *Italic text*
[Check out this link](https://github.com/mikepenz/multiplatform-markdown-renderer)
""".trimIndent()
)
[!NOTE]
Import either com.mikepenz.markdown.m3.Markdown for Material 3 or
com.mikepenz.markdown.m2.Markdown for Material 2 themed applications.
[!NOTE]
By default, when the markdown content changes, the component will display a loading state while
parsing the new content. To keep the previous content visible during updates and avoid showing the
loading state, set retainState to true.
Image Loading
To configure image loading, the library offers different implementations, to offer great flexibility
for the respective integration.
After adding the dependency, the chosen image transformer implementation has to be passed to the
Markdown API.
[!NOTE]
Please refer to the official documentation for the specific image loading integration you are
using (e.g., coil3) on how to adjust its
behavior.
coil3
// Offers coil3 (Coil3ImageTransformerImpl)
implementation("com.mikepenz:multiplatform-markdown-renderer-coil3:${version}")
Markdown(
MARKDOWN,
imageTransformer = Coil3ImageTransformerImpl,
)
coil2
// Offers coil2 (Coil2ImageTransformerImpl)
implementation("com.mikepenz:multiplatform-markdown-renderer-coil2:${version}")
Markdown(
MARKDOWN,
imageTransformer = Coil2ImageTransformerImpl,
)
Syntax Highlighting
The library (introduced with 0.27.0) offers optional support for syntax highlighting via
the Highlights project.
This support is not included in the core, and can be enabled by adding the
multiplatform-markdown-renderer-code
dependency.
implementation("com.mikepenz:multiplatform-markdown-renderer-code:${version}")
Once added, the Markdown has to be configured to use the alternative code highlighter.
Markdown(
MARKDOWN,
components = markdownComponents(
codeBlock = highlightedCodeBlock,
codeFence = highlightedCodeFence,
)
)
val isDarkTheme = isSystemInDarkTheme()
val highlightsBuilder = remember(isDarkTheme) {
Highlights.Builder().theme(SyntaxThemes.atom(darkMode = isDarkTheme))
}
Markdown(
MARKDOWN,
components = markdownComponents(
codeBlock = {
MarkdownHighlightedCodeBlock(
content = it.content,
node = it.node,
highlightsBuilder = highlightsBuilder,
showHeader = true,
)
},
codeFence = {
MarkdownHighlightedCodeFence(
content = it.content,
node = it.node,
highlightsBuilder = highlightsBuilder,
showHeader = ,
)
},
)
)
Dependencies
This library uses the following key dependencies:
- JetBrains Markdown - Multiplatform Markdown processor
for parsing markdown content
- Compose Multiplatform - For cross-platform
UI rendering
- Extended Spans - For advanced text styling (integrated
as multiplatform)
- Highlights - For code syntax highlighting (optional)
Developed By
Contributors
This free, open source software was made possible by a group of volunteers who put many hours of
hard work into it. See the CONTRIBUTORS.md file for details.
Credits
Big thanks to Erik Hellman and his awesome article
on Rendering Markdown with Jetpack Compose,
and the related source MarkdownComposer.
Also huge thanks to Saket Narayan for his great work on
the extended-spans project, which was ported into this
project to make it multiplatform.
Fork License
Copyright for portions of the code are held by [Erik Hellman, 2020] as part of
project MarkdownComposer under the MIT license.
All other copyright for project multiplatform-markdown-renderer are held by [Mike Penz, 2023] under
the Apache License, Version 2.0.
License
Copyright 2025 Mike Penz
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http:
Unless applicable law agreed to writing, software
distributed under the License distributed an BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express implied.
See the License the specific language governing permissions
limitations under the License.