ComposableFieldValue

Interface for values that can be used in a ComposableField. Provides a label and composable content.

Usage

// Using predefined values
@Preview
@Composable
fun MyPreview() = PreviewLab {
val content: @Composable () -> Unit = fieldValue {
ComposableField(
label = "Content",
initialValue = ComposableFieldValue.Red64X64,
choices = listOf(
ComposableFieldValue.Red32X32,
ComposableFieldValue.Red64X64,
ComposableFieldValue.SimpleText,
ComposableFieldValue.Empty
)
)
}
MyBox(content = content)
}

// Creating custom ComposableFieldValue
val CustomIcon: ComposableFieldValue = object : ComposableFieldValue {
override val label: String = "Custom Icon"

@Composable
override fun invoke() {
Icon(Icons.Default.Star, contentDescription = null)
}
}

// Using in a preview
@Preview
@Composable
fun CustomPreview() = PreviewLab {
val icon: @Composable () -> Unit = fieldValue {
ComposableField(
label = "Icon",
initialValue = CustomIcon
)
}
MyButton(icon = icon)
}

See also

Inheritors

Types

Link copied to clipboard

A ComposableFieldValue that renders a colored box with configurable dimensions. Supports both fixed dimensions and fill options.

Link copied to clipboard
object Companion
Link copied to clipboard

An empty ComposableFieldValue that renders nothing.

Link copied to clipboard
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.

Properties

Link copied to clipboard
abstract val label: String

Display label for this composable value

Functions

Link copied to clipboard
abstract operator fun invoke()

Renders the composable content