https://kotlinlang.org logo
#compose-web
Title
# compose-web
s

spierce7

03/29/2024, 9:50 PM
Is it possible to integrate compose HTML and compose canvas composables together?
m

mohamed rejeb

03/30/2024, 5:50 AM
Yes, it's possible, create a canvas inside Compose HTML and then in Compose Canvas target that canvas id and you will have both in the same app. You can also share states between the two.
Copy code
fun main() {
    val viewmodel = remember { ViewModel() }
    // compose html code here
    // canvas with id "canvasId"

    // compose canvas code here
    onWasmReady {
        CanvasBasedWindow(
            title = "Title",
            canvasElementId = "canvasId",
        ) {

        }
    }
}
s

spierce7

04/01/2024, 12:23 PM
Can you position compose html elements inside of or on top of compose html in the same layout hierarchy or do you have to maintain 2 separate layouts entirely?
8 Views