Composables
Docs Login
Vela

Text

Jetpack Compose Component

Download
package com.composables.vela.components

import androidx.compose.foundation.text.BasicText
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.isSpecified
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextOverflow
import com.composables.vela.theme.LocalContentColor
import com.composables.vela.theme.LocalTextStyle

@Composable
fun Text(
    text: String,
    modifier: Modifier = Modifier,
    color: Color = Color.Unspecified,
    style: TextStyle = LocalTextStyle.current,
    overflow: TextOverflow = TextOverflow.Clip,
    softWrap: Boolean = true,
    maxLines: Int = Int.MAX_VALUE,
) {
    val resolvedColor =
        when {
            color.isSpecified -> color
            style.color.isSpecified -> style.color
            else -> LocalContentColor.current
        }
    BasicText(
        text = text,
        modifier = modifier,
        style = LocalTextStyle.current.merge(style).copy(color = resolvedColor),
        overflow = overflow,
        softWrap = softWrap,
        maxLines = maxLines,
    )
}

More components from Vela

by Alex Styl

Search screens and components

Screen flows

Screens

UI Elements

One Android lesson, every Wednesday

Building Android apps?

What Alex learned building Android apps for 14 years, so you don't have to. Reads in under a minute.

Join 3,500+ Android developers. Unsubscribe any time.

You're subscribed

The next lesson lands in on Wednesday.