withHintAction
fun <Value> MutablePreviewLabField<Value>.withHintAction(vararg choices: Pair<String, suspend MutablePreviewLabField<Value>.() -> Unit>): MutablePreviewLabField<Value>
Adds hint actions to a MutablePreviewLabField, allowing users to execute custom actions.
This function allows executing arbitrary actions on the field when a hint is selected. The action receives the field as its receiver, enabling direct manipulation of the field's value or other properties.
Usage
@Preview
@Composable
fun ListPreview() = PreviewLab {
val items: List<String> = fieldValue {
ListField(
label = "items",
elementField = { StringField(label, initialValue) },
initialValue = emptyList(),
)
.withHintAction(
"Add 3 items" to { value = value + listOf("Item A", "Item B", "Item C") },
"Clear all" to { value = emptyList() }
)
}
ItemList(items = items)
}Content copied to clipboard
Return
A WithHintField wrapper that displays the base field with action hints
Parameters
choices
Vararg of pairs where first is the hint label and second is the action to execute