InspectorTab
interface InspectorTab
Represents a tab in the PreviewLab inspector panel.
Built-in tabs (Fields and Events) are provided by InspectorTab.Fields and InspectorTab.Events. Custom tabs can be created by implementing this interface.
Creating Custom Tabs
To create a custom tab, implement this interface with your own tab content:
object CustomTab : InspectorTab {
override val title = "Custom"
override val icon: @Composable () -> Painter = { painterResource(PreviewLabUiRes.drawable.icon_custom) }
@Composable
override fun ContentContext.Content() {
// Your custom tab content can access state via the ContentContext
Column {
Text("Custom Tab Content")
Text("Field count: ${state.scope.fields.size}")
}
}
}Content copied to clipboard
Then pass it to PreviewLab via the inspectorTabs parameter:
// Default tabs (Fields, Events) + custom tab
@Preview
@Composable
fun MyPreview() = PreviewLab(
inspectorTabs = InspectorTab.defaults + listOf(CustomTab)
) {
MyComponent()
}
// Custom tabs only (no default tabs)
@Preview
@Composable
fun MyPreview() = PreviewLab(
inspectorTabs = listOf(CustomTab)
) {
MyComponent()
}Content copied to clipboard
Inheritors
Types
Link copied to clipboard
Link copied to clipboard
Context providing access to PreviewLabState for tab content.
Link copied to clipboard
Built-in Events tab that displays all logged events.
Link copied to clipboard
Built-in Fields tab that displays all interactive fields.
Properties
Functions
Link copied to clipboard
The content to display when the tab is selected. Implement this composable function within ContentContext receiver scope to access the PreviewLabState via ContentContext.state.