New Compose Multiplatform components arrived on Composables UICheck it out →

Component in Compose Ui



Compose [Window] obtained from [create]. The [create] block will be called exactly once to obtain the [Window] to be composed, and it is also guaranteed to be invoked on the UI thread (Event Dispatch Thread).

Once [AwtWindow] leaves the composition, [dispose] will be called to free resources that obtained by the [Window].

The [update] block can be run multiple times (on the UI thread as well) due to recomposition, and it is the right place to set [Window] properties depending on state. When state changes, the block will be reexecuted to set the new properties. Note the block will also be ran once right after the [create] block completes.

[AwtWindow] is needed for creating window's / dialog's that still can't be created with the default Compose functions [androidx.compose.ui.window.Window] or [androidx.compose.ui.window.Dialog].

Last updated:


dependencies {


fun <T : Window> AwtWindow(
    visible: Boolean = true,
    create: () -> T,
    dispose: (T) -> Unit,
    update: (T) -> Unit = {}


visibleIs [Window] visible to user. Note that if we set false - native resources will not be released. They will be released only when [Window] will leave the composition.
createThe block creating the [Window] to be composed.
disposeThe block to dispose [Window] and free native resources. Usually it is simple Window::dispose
updateThe callback to be invoked after the layout is inflated.