Access to CSS attributes with dash in name


#1

Hi all !

I’m struggling with accessing, in Kotlin code, CSS attributes that contains “-” in name. Following code fails:

label { attrs.jsStyle.text-align = "center" }
How should I access “text-align” property through jsStyle ?


#2

Use backticks ( ` ), same as in Kotlin/JVM:

label { attrs.jsStyle.`text-align` = "center" }

Or cast to dynamic and use square brackets:

label { attrs.jsStyle.asDynamic()["text-align"] = "center" }