Text

class Text(val text: String, val fontScale: Float = 1.0f, label: String? = null, textStyle: TextStyle? = null) : ComposableFieldValue

A ComposableFieldValue that renders text with optional font scaling and styling.

Usage

// Basic text content
@Preview
@Composable
fun TextPreview() = PreviewLab {
val content: @Composable () -> Unit = fieldValue {
ComposableField(
label = "Content",
initialValue = ComposableFieldValue.Text("Hello World"),
choices = listOf(
ComposableFieldValue.Text("Short text"),
ComposableFieldValue.Text("Medium length text here"),
ComposableFieldValue.Text("Very long text that might wrap to multiple lines")
)
)
}
MyTextContainer(content = content)
}

// With font scaling
@Preview
@Composable
fun ScaledTextPreview() = PreviewLab {
val label: @Composable () -> Unit = fieldValue {
ComposableField(
label = "Label",
initialValue = ComposableFieldValue.Text("Normal", fontScale = 1.0f),
choices = listOf(
ComposableFieldValue.Text("Small", fontScale = 0.8f, label = "Small (0.8x)"),
ComposableFieldValue.Text("Normal", fontScale = 1.0f, label = "Normal (1.0x)"),
ComposableFieldValue.Text("Large", fontScale = 1.5f, label = "Large (1.5x)")
)
)
}
MyCard(label = label)
}

// Using predefined text values
@Preview
@Composable
fun PredefinedTextPreview() = PreviewLab {
val content: @Composable () -> Unit = fieldValue {
ComposableField(
label = "Content",
initialValue = ComposableFieldValue.SimpleText,
choices = listOf(
ComposableFieldValue.ShortText,
ComposableFieldValue.SimpleText,
ComposableFieldValue.HeadingText,
ComposableFieldValue.BodyText,
ComposableFieldValue.LongText
)
)
}
MyArticle(content = content)
}

@param text The text content to display
@param fontScale Scale factor for the font size (default: 1f)
@param label Optional custom label (defaults to generated label)
@param textStyle Optional text style to apply
@see ComposableField

Constructors

Link copied to clipboard
constructor(text: String, fontScale: Float = 1.0f, label: String? = null, textStyle: TextStyle? = null)

Properties

Link copied to clipboard
Link copied to clipboard
open override val label: String

Display label for this composable value

Link copied to clipboard

Functions

Link copied to clipboard
open operator override fun invoke()

Renders the composable content