PreviewLabGalleryWindows

fun ApplicationScope.PreviewLabGalleryWindows(previewList: List<PreviewLabPreview>, openFileHandler: OpenFileHandler<out Any?>? = null, featuredFileList: Map<String, List<String>> = emptyMap(), state: PreviewLabGalleryState = remember { PreviewLabGalleryState() }, noSelectedContents: @Composable (Map<String, List<PreviewLabPreview>>) -> Unit = { groupedPreviews -> PreviewListGrid( groupedPreviewList = groupedPreviews, onPreviewClick = { group, preview -> state.select(group, preview) }, contentPadding = PaddingValues(adaptive(12.dp, 20.dp)), ) }, mcpServerConfig: PreviewLabMcpServerConfig = PreviewLabMcpServerConfig(), windowState: WindowState = rememberWindowState(size = DpSize(1000.dp, 800.dp)), onCloseRequest: () -> Unit = ::exitApplication, visible: Boolean = true, title: String = "Compose Preview Lab", icon: Painter? = null, undecorated: Boolean = false, transparent: Boolean = false, resizable: Boolean = true, enabled: Boolean = true, focusable: Boolean = true, alwaysOnTop: Boolean = false, onPreviewKeyEvent: (KeyEvent) -> Boolean = { false }, onKeyEvent: (KeyEvent) -> Boolean = { false })

Creates a desktop window application for previewing Compose components

Launches a JVM desktop application with PreviewLab interface in a native window. Provides full desktop integration with customizable window properties for interactive component development and testing.

// Basic desktop application
fun main() = application {
PreviewLabGalleryWindows(
previewList = myModule.PreviewList
)
}

// With file handler and featured files
fun main() = application {
PreviewLabGalleryWindows(
previewList = myModule.PreviewList,
openFileHandler = UrlOpenFileHandler("https://github.com/user/repo/blob/main"),
featuredFileList = myModule.FeaturedFileList,
)
}

// Custom window configuration
fun main() = application {
PreviewLabGalleryWindows(
previewList = myModule.PreviewList,
windowState = rememberWindowState(size = DpSize(1400.dp, 900.dp)),
title = "My Component Gallery",
)
}

Parameters

previewList

Collection of previews to display in the interface

openFileHandler

Handler for opening source files (optional)

featuredFileList

Grouped file organization for navigation

state

PreviewLabGalleryState for managing gallery state

windowState

WindowState for managing window properties

onCloseRequest

Callback invoked when window close is requested

visible

Whether the window is visible

title

Window title text

icon

Window icon painter

undecorated

Whether to remove window decorations

transparent

Whether the window background is transparent

resizable

Whether the window can be resized

enabled

Whether the window is enabled for user interaction

focusable

Whether the window can receive focus

alwaysOnTop

Whether the window should stay on top of other windows

noSelectedContents

Content to display when no preview is selected

mcpServerConfig

Configuration for the MCP server (experimental feature). The MCP server allows AI assistants to interact with previews. Use PreviewLabMcpServerConfig.Disable to disable the MCP server.

onPreviewKeyEvent

Callback for preview key events

onKeyEvent

Callback for key events

See also