Skip to content
🤔 Documentation issue? Report or edit

Text

You can use Text to display text. You can use the style argument to define things like textdecoration or fontfamily.

@Composable
fun TextExample(){
     Column {
            Text("Just Text")
            Text("Text with cursive font", style = TextStyle(fontFamily = FontFamily.Cursive))
            Text(
                text = "Text with LineThrough",
                style = TextStyle(textDecoration = TextDecoration.LineThrough)
            )
            Text(
                text = "Text with underline",
                style = TextStyle(textDecoration = TextDecoration.Underline)
            )
            Text(
                text = "Text with underline, linethrough and bold",
                style = TextStyle(
                    textDecoration = TextDecoration.combine(
                        listOf(
                            TextDecoration.Underline,
                            TextDecoration.LineThrough
                        )
                    ), fontWeight = FontWeight.Bold
                )
            )
        }
}

Working with Text

Normal text

@Composable
fun NormalTextExample(){
    Text("Just Text")
}

Cursive text

@Composable
fun CursiveTextExample(){
    Text("Text with cursive font", style = TextStyle(fontFamily = Cursive))
}

Text with LineThrough

@Composable
fun TextWithLineThroughExample(){
    Text(
        text = "Text with LineThrough",
        style = TextStyle(textDecoration = TextDecoration.LineThrough)
    )
}

Text with underline

@Composable
fun TextWithUnderline(){
    Text(
        text = "Text with underline",
        style = TextStyle(textDecoration = TextDecoration.Underline)
    )
}

Text with underline, bold and linethrough

@Composable
fun TextWithUnderlineStrikeThroughAndBold(){
    Text(
        text = "Text with underline, linethrough and bold",
        style = TextStyle(
            textDecoration = TextDecoration.combine(
                listOf(
                    TextDecoration.Underline,
                    TextDecoration.LineThrough
                )
            ), fontWeight = FontWeight.Bold
        )
    )
}

See also:


Last update: August 3, 2022