ComposePreviewLabOption
annotation class ComposePreviewLabOption(val displayName: String = "{{qualifiedName}}", val ignore: Boolean = false, val id: String = "{{qualifiedName}}")
usages
By default, the qualifiedName of the Preview (ex. com.example.my.buttons.MyButtonPreview) is used as the Preview name, but this can be overridden by displayName. The name MyButtonPreview can be displayed on ComposePreviewLab by specifying the following.
package com.example.my.buttons
@ComposePreviewLabOption(displayName = "{{simpleName}}")
@Preview
@Composable
fun MyButtonPreview() {
MyButton()
}
@ComposePreviewLabOption(displayName = "{{simpleName}}.Red")
@Preview
@Composable
fun MyButtonRedPreview() {
MyButton(color = Color.Red)
}Content copied to clipboard
Options such as displayName allow placeholders in the form {{placeholderName}}. Supported placeholder meanings are as follows
{{package}} ... the package name of the Preview, e.g.
com.example.my.buttons.{{simpleName}} ... the simple name of the Preview, e.g.
MyButtonPreview.{{qualifiedName}} ... the fully qualified name of the Preview, e.g.
com.example.my.buttons.MyButtonPreviewKt.MyButtonPreviewif the Preview is defined in a file namedMyButtonPreview.kt.