All Projects → Kotlin → kotlinx.html

Kotlin / kotlinx.html

Licence: Apache-2.0 license
Kotlin DSL for HTML

Programming Languages

kotlin
9241 projects

Labels

Kotlin Stable Official JetBrains Project GitHub license Kotlin npm TeamCity (simple build status)

kotlinx.html

A kotlinx.html library provides DSL to build HTML to Writer/Appendable or DOM. Available to all Kotlin Multiplatform targets and browser(or other JavaScript engine) for better Kotlin programming for Web.

Get started

See Getting started page for details how to include the library.

DOM

You can build DOM tree with JVM and JS naturally

See example for JavaScript-targeted Kotlin

window.setInterval({
    val myDiv = document.create.div("panel") {
        p { 
            +"Here is "
            a("https://kotlinlang.org") { +"official Kotlin site" }
        }
    }

    document.getElementById("container")!!.appendChild(myDiv)

    document.getElementById("container")!!.append {
        div {
            +"added it"
        }
    }
}, 1000L)

Stream

You can build HTML directly to Writer (JVM) or Appendable (Multiplatform)

System.out.appendHTML().html {
    body {
        div {
            a("https://kotlinlang.org") {
                target = ATarget.blank
                +"Main site"
            }
        }
    }
}

Documentation

See wiki pages

Building

See development page for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].