Hi, I am doing the tutorial to build a ShoppingLis...
# multiplatform
h
Hi, I am doing the tutorial to build a ShoppingList full stack app, and I was wondering how to add a class/id attribute for HTML on App.kt. For example,
h1 {+"Full-Stack Shopping List"}
-> I want to write something like this:
h1(classes="hello"){+"Full-Stack Shopping List"}
I realized that for id, I can simply write:
h1 {id = "hello" +"Full-Stack Shopping List"}
. I have researched and it seems like using kotlinx.html (https://github.com/Kotlin/kotlinx.html) might be the solution. However,
h1("hello"){+"Full-Stack Shopping List"}
doesn't work. Does anyone know how to add a class attribute specifically in the App.kt on the tutorial. (https://kotlinlang.org/docs/multiplatform-full-stack-app.html#build-the-user-interface)?
c
I'm not sure what you're searching for, but the tutorial you linked uses Kotlin React (https://github.com/JetBrains/kotlin-wrappers/tree/master/kotlin-react-dom) and not KotlinX.html
h
I want to write something like this:
<div class="hello">
in kotlin. Is there a way to add a class attribute? I realize that
<div id="hello">
is equivalent to
div {id = "hello"}
.
c
It depends on the wrapper. If I recall correctly, Kotlin React uses
classes = "stuff"
. Compose Web uses
classes("stuff")
. Check which one you're using, then maybe ask again in #kotlinx-html, #react or #compose-web for specifics
h
I see. Thank you for the help!