SizeField
Field for editing Compose Size values (width, height in pixels)
Provides separate input fields for width and height dimensions in pixels. Used for defining component sizes, canvas dimensions, or geometric measurements. Each dimension can be edited independently through dedicated text fields.
Usage
// Canvas size field
@Preview
@Composable
fun CanvasSizePreview() = PreviewLab {
val canvasSize: Size = fieldValue { SizeField("Canvas", Size(200f, 150f)) }
Canvas(
modifier = Modifier.size(
width = canvasSize.width.dp,
height = canvasSize.height.dp
)
) {
drawRect(Color.Blue)
}
}
// Rectangle dimensions
@Preview
@Composable
fun RectangleSizePreview() = PreviewLab {
val rectSize: Size = fieldValue { SizeField("Rectangle", Size(100f, 50f)) }
Canvas(modifier = Modifier.size(200.dp)) {
drawRect(
color = Color.Red,
size = rectSize
)
}
}Parameters
Display label for the field
Starting Size value
See also
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.