HtmlText
A Kotlin Multiplatform library to render HTML content as Compose AnnotatedString, supporting basic formatting and hyperlinks.
Install / Use
/learn @ch4rl3x/HtmlTextREADME
<a href="https://github.com/ch4rl3x/HtmlText/actions?query=workflow%3ABuild"><img src="https://github.com/ch4rl3x/HtmlText/actions/workflows/build.yml/badge.svg" alt="Build"></a> <a href="https://www.codefactor.io/repository/github/ch4rl3x/HtmlText"><img src="https://www.codefactor.io/repository/github/ch4rl3x/HtmlText/badge" alt="CodeFactor" /></a> <a href="https://repo1.maven.org/maven2/de/charlex/compose/html-text-material3/"><img src="https://img.shields.io/maven-central/v/de.charlex.compose/html-text-material3" alt="Maven Central" /></a>
HtmlText
HtmlText is a Kotlin Multiplatform library that allows you to render HTML content as Compose AnnotatedStrings. It supports basic formatting, hyperlinks, and color styling in a multiplatform-friendly way. HtmlText has been made accessible for screen readers and keyboard operation.
[!WARNING]
Starting with version 3.0.0-beta02, the Maven GroupId has changed tode.charlex.composeand artifact names changed frommaterial-html-texttohtml-text-material.
[!NOTE]
🚀 HtmlText is now Compose Multiplatform
Supported HTML tags
| Tag | Description |
|------------------------------------|---------------------------|
| <b> | Bold text |
| <i> | Italic text |
| <strike> | Strikethrough text |
| <u> | Underlined text |
| <ul> | Unordered list |
| <ol start="3" type="1"> | Ordered list (a., A., 1.) |
| <li> | List item |
| <a href="..."> | Clickable link |
| <span style="color: #0000FF"> | Colored text |
| <span style="color: rgb(r,g,b)"> | Colored text |
| <font color="#FF0000"> | Colored text |
| <font color="rgb(r,g,b)"> | Colored text |
MaterialTheme colors in HtmlText
To use colors like MaterialTheme.colors.primary in HtmlText, map simple colors.
HtmlText(
stringId = R.string.hello_world_cdata,
colorMapping = mapOf(Color.Red to MaterialTheme.colors.primary)
)
<resources>
<string name="hello_world_escaped">Hello <span style="color: #FF0000">World</span></string>
<string name="hello_world_cdata"><![CDATA[Hello <span style="color: #FF0000">World</span>]]></string>
</resources>
Preview

Dependency
Add actual HtmlText library:
dependencies {
implementation 'de.charlex.compose:html-text-material:3.0.0-beta02'
}
or
dependencies {
implementation 'de.charlex.compose:html-text-material3:3.0.0-beta02'
}
License
Copyright 2025 Alexander Karkossa
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://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
