
Enables rendering HTML text in a text composable, supporting tags for bold, italic, links, and colors. Allows integration of theme colors and string arguments for flexible text styling.
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
| 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="https://github.com/ch4rl3x/HtmlText/blob/main/..."> |
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 |
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>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'
}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.
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
| 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="https://github.com/ch4rl3x/HtmlText/blob/main/..."> |
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 |
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>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'
}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.