DSL slides¶
dslSlide { } exposes the kotlinx.html builder. The generated HTML is type-safe, refactorable, and can include arbitrary Kotlin logic.
Basic usage¶
fun dslBasic() {
kslides {
presentation {
dslSlide {
content {
h1 { +"Kotlin HTML DSL" }
p { +"Build slides with kotlinx.html." }
}
}
}
}
}
Every kotlinx.html tag function is available inside content { }: h1, p, ul, img, section, etc.
Generated content¶
Because the DSL is just Kotlin, you can compose slides from data:
fun dslLoop() {
val items = listOf("Type-safe", "Refactorable", "Composable")
kslides {
presentation {
dslSlide {
content {
h2 { +"Why DSL slides?" }
ul {
items.forEach { li { +it } }
}
}
}
}
}
}
When to reach for the DSL¶
- The slide is generated from data (a list, an API response, a file scan).
- You want compile-time checks on tag and attribute names.
- You're embedding kslides extensions like
playground { },diagram { }, orcodeSnippet { }— those live insidedslSlide { content { ... } }.