Home › Free tools › Compose text style generator
Free Android dev tool · No signup

Compose Text style generator underline, bold, colour and links

Style a Jetpack Compose Text with a live preview: size, weight, italic, underline or strikethrough, colour, font, alignment and max lines. Style just one word or turn it into a clickable link – then copy the Kotlin code.

Underline & strikethroughStyle one word with AnnotatedStringClickable links
Start from:

Hello Compose

Preview is an approximation in your browser – Android renders fonts slightly differently.

How to underline text in Jetpack Compose

Pass textDecoration = TextDecoration.Underline to Text. For a strikethrough use TextDecoration.LineThrough, and for both use TextDecoration.combine(listOf(TextDecoration.Underline, TextDecoration.LineThrough)).

Text(
    text = "Forgot password?",
    textDecoration = TextDecoration.Underline
)

Underline or colour just one word

A plain String can only have one style. To style part of the text, build an AnnotatedString with buildAnnotatedString and wrap the word in withStyle(SpanStyle(…)):

val text = buildAnnotatedString {
    append("Read the ")
    withStyle(SpanStyle(textDecoration = TextDecoration.Underline)) {
        append("guide")
    }
}
Text(text)

Make a word clickable

Since Compose 1.7 you can add links inside text with withLink(LinkAnnotation.Url("https://…")). The link opens in the browser by default and works with accessibility services. Choose “Make one word a link” above to generate it.

Other common Text settings

  • Bold – fontWeight = FontWeight.Bold (or SemiBold, Medium…).
  • Size – fontSize = 16.sp. Use sp, not dp, so text follows the user’s font size setting (see our dp, sp and px converter).
  • Cut long text with “…” – maxLines = 2, overflow = TextOverflow.Ellipsis.
  • Centre text – textAlign = TextAlign.Center works when the Text is wider than its content, for example with Modifier.fillMaxWidth().

New to Kotlin? Our free Kotlin course teaches the basics step by step.

More free tools you may like

See all 99 free tools →

Frequently asked questions

How do I underline text in Jetpack Compose?

Add textDecoration = TextDecoration.Underline to your Text. Import it from androidx.compose.ui.text.style.TextDecoration.

How do I add a strikethrough in Compose?

Use textDecoration = TextDecoration.LineThrough. To show both underline and strikethrough, use TextDecoration.combine(listOf(TextDecoration.Underline, TextDecoration.LineThrough)).

How do I make only part of the text bold or underlined?

Build an AnnotatedString: buildAnnotatedString { append("Hello "); withStyle(SpanStyle(fontWeight = FontWeight.Bold)) { append("world") } }, then pass it to Text.

How do I make a clickable link inside Text in Compose?

With Compose 1.7 or newer, use withLink(LinkAnnotation.Url("https://…")) { append("link text") } inside buildAnnotatedString. Older code used ClickableText, which is now deprecated.

How do I show “…” when text is too long?

Set maxLines and overflow = TextOverflow.Ellipsis, for example maxLines = 1 for a single-line title.

Should I use sp or dp for font size?

Use sp. sp follows the user’s font size setting in Accessibility, so your app stays readable for people who need larger text.

Need an Android app built?

We design and build Android apps in Kotlin and Jetpack Compose for clients worldwide – clear scope, fixed price, fast delivery.

Techpass Master Technologies · Websites, Android apps and digital marketing

WhatsApp us📞 Call now