StringField
A field that allows users to input a string value.
Usage
// Basic usage
@Preview
@Composable
fun TextPreview() = PreviewLab {
val text: String = fieldValue { StringField("Text", "Hello World!!") }
Text(text = text)
}
// With prefix and suffix
@Preview
@Composable
fun UrlPreview() = PreviewLab {
val path: String = fieldValue {
StringField(
label = "Path",
initialValue = "home",
prefix = { Text("https://example.com/") },
suffix = { Icon(Icons.Default.Link, null) }
)
}
Text(text = "URL: https://example.com/$path")
}
// For multiline text input
@Preview
@Composable
fun DescriptionPreview() = PreviewLab {
val description: String = fieldValue {
StringField(
label = "Description",
initialValue = "Enter your description here..."
)
}
Text(text = description)
}Parameters
The slot that will be displayed as the prefix of the TextField.
The slot that will be displayed as the suffix of TextField.
Constructors
Functions
Composable, which displays the main UI for this Field. If you want to customize the UI, you can override this method in your PreviewLabField to customize the UI.
Default UI implementation of me.tbsten.compose.preview.lab.PreviewLabField.View. Display a label and draw the content below it.
Display the label of PreviewLabField.
Create a PreviewLabField that makes the receiver's PreviewLabField nullable.
Returns a KSerializer for this field's value type, or null if serialization is not supported.
Returns a list of representative values for this field to be used in automated testing.
Helper for UI of Fields that can be input with TextField.
Transforms a MutablePreviewLabField to work with a different value type.
Composable, which displays the entire UI for this Field. If you want to customize the UI, you can override this method in your PreviewLabField to customize the UI. However, in many cases where the UI is customized, overriding the content method is more appropriate.
Adds hint choices to a MutablePreviewLabField, allowing users to quickly select from predefined values.
Adds predefined color hints to a Color field for quick selection.
Wraps this field with a custom me.tbsten.compose.preview.lab.PreviewLabField.serializer implementation.
Wraps this field with a custom me.tbsten.compose.preview.lab.PreviewLabField.valueCode implementation.
Wraps this field with additional composable content.