Hello, I just wanted to ask if someone has an example on how to create standard web components using Kotlin. Thanks!
s
Stan van der Bend
02/09/2025, 10:00 PM
Heya, what do you mean by standard web components? It would help if you gave some examples! technically you can do (almost?) anything in Kotlin anything you can do in JS as its interoperable, however some frameworks are not supported out of the box.
I would take a look at compose for web (WasmJS) or compose html (kotlin for JS) if you want an easy to understand framework to create reactive components.
But KotlinJS also has a nice type-safe html dsl .
Another good resource in general is: https://klibs.io
(Also 😉 : https://stackoverflow.com/help/how-to-ask)
t
turansky
02/09/2025, 10:58 PM
@jaguililla what is your use case?
Do you need it internal use (inside the same application)?
Or you want to create component's library?
In both cases some additional pills will be required.
Sorry for the lack of details and thanks for the replies @Stan van der Bend, @turansky, and @Edoardo Luppi. By standard Web Components, I meant the components that you can create using W3C standards (as defined in MDN: https://developer.mozilla.org/en-US/docs/Web/API/Web_components). I wanted to create one component using Kotlin being the closest it could get to the actual JS code, ideally, I would love to implement the example I found here:
https://www.youtube.com/watch?v=2I7uX8m0Ta0â–¾
, but in Kotlin. The issue posted by @Edoardo Luppi is my answer, thanks! By reading the issue, I understand that there is a problem extending HTMLElements that prevent components definitions (at least as it is done in JS). As the blocker issue is dated 4y ago, I suppose it is not a priority 😢