OudsCodeText
Code style is dedicated to technical content such as code snippets, commands, system values, and identifiers. It uses a monospace typeface to preserve character alignment and improve readability of structured content. Available in a single size, it provides a consistent presentation of technical information throughout the product. Its use should be limited to content that requires an accurate code-like representation.
An overload accepting annotated string is available for rich text formatting.
Design
| Name | Code |
| Version | 1.0.0 |
Parameters
Text to be displayed.
Modifier applied to the code text.
Color of the code text.
Alignment of the text within the lines of the paragraph. See TextStyle.textAlign.
Line height for the Paragraph in TextUnit unit, e.g. SP or EM. See TextStyle.lineHeight.
How visual overflow should be handled.
Callback that is executed when a new text layout is calculated. A TextLayoutResult object that callback provides contains paragraph information, size of the text, baselines and other details. The callback can be used to add additional decoration or functionality to the text. For example, to draw selection around the text.
Samples
OudsCodeText(
modifier = Modifier.padding(OudsTheme.spaces.fixed.small),
text = "Code",
)Code style is dedicated to technical content such as code snippets, commands, system values, and identifiers. It uses a monospace typeface to preserve character alignment and improve readability of structured content. Available in a single size, it provides a consistent presentation of technical information throughout the product. Its use should be limited to content that requires an accurate code-like representation.
An overload accepting plain text is available for simple text without formatting.
Design
| Name | Code |
| Version | 1.0.0 |
Parameters
Text to be displayed. Note: Use rich text in compliance with guidelines and accessibility criteria.
Modifier applied to the code text.
Color of the code text.
Alignment of the text within the lines of the paragraph. See TextStyle.textAlign.
Line height for the Paragraph in TextUnit unit, e.g. SP or EM. See TextStyle.lineHeight.
How visual overflow should be handled.
Callback that is executed when a new text layout is calculated. A TextLayoutResult object that callback provides contains paragraph information, size of the text, baselines and other details. The callback can be used to add additional decoration or functionality to the text. For example, to draw selection around the text.
Samples
OudsCodeText(
modifier = Modifier.padding(OudsTheme.spaces.fixed.small),
text = buildAnnotatedString {
append("Code with ")
withStyle(SpanStyle(color = OudsTheme.colorScheme.content.brandPrimary)) { append("colored text") }
append(" and ")
withStyle(SpanStyle(fontWeight = FontWeight.Bold)) { append("bold text") }
}
)