SelectableField
fun <Value> SelectableField(label: String, type: SelectableField.Type = DROPDOWN, builder: SelectableField.Builder<Value>.() -> Unit): SelectableField<Value>
Create a SelectableField with the given label and choices using a builder syntax.
Usage
@Preview
@Composable
fun MyPreview() = PreviewLab {
val alignment: Alignment = fieldValue {
SelectableField<Alignment>(label = "Alignment") {
choice(Alignment.Start, "Start", isDefault = true)
choice(Alignment.Center, "Center")
choice(Alignment.End, "End")
}
}
MyComponent(alignment = alignment)
}Content copied to clipboard
See also
fun <Value> SelectableField(label: String, choices: Map<String, Value>, type: SelectableField.Type = DROPDOWN, initialValue: Value = choices.entries.first().value): SelectableField<Value>
Create a SelectableField with the given label and choices from a map.
Usage
@Preview
@Composable
fun MyPreview() = PreviewLab {
val language: Locale = fieldValue {
SelectableField(
label = "Language",
choices = mapOf(
"English" to Locale.ENGLISH,
"Japanese" to Locale.JAPANESE,
"French" to Locale.FRENCH
)
)
}
MyApp(locale = language)
}Content copied to clipboard