applyStyle

fun StyleScope.applyStyle(textAlign: TextAlign)(source)
fun StyleScope.applyStyle(textDecoration: TextDecoration)(source)


fun StyleScope.applyStyle(textOverflow: TextOverflow, softWrap: Boolean, maxLines: Int)(source)

Applies text overflow, wrapping, and line clamping CSS styles.

Note on maxLines vs minLines CSS implementation inconsistency:

  • maxLines uses -webkit-line-clamp with display: -webkit-box and -webkit-box-orient: vertical, which is the only widely-supported CSS mechanism for multi-line text truncation. The standard line-clamp property (without -webkit- prefix) is not yet widely supported.

  • minLines uses min-height with lh (line-height) units, as there is no CSS equivalent to min-line-clamp.

Note on TextOverflow.Visible degradation when maxLines is set: -webkit-line-clamp requires overflow: hidden to function, so TextOverflow.Visible effectively degrades to Clip when maxLines is set on JS DOM. There is no CSS way to both limit visible lines and allow text to overflow beyond its bounds.

Note on softWrap and maxLines interaction: In Compose UI, when softWrap is false, the text is always single-line and maxLines is ignored. On JS DOM, white-space: nowrap achieves the same single-line behavior, so -webkit-line-clamp is only applied when softWrap is true.