Type-safe CSS

TornadoFX provides type-safe CSS, which enables autocompletion, and checks at compilation time to conveniently create styles in its own class or provide inline styling. It's recommended to provide a Stylesheet method if you want to reuse and organize your styles. Take a look at the following code snippet:

    class Styles : Stylesheet() {      companion object {        val appSizeRule by cssclass()      }      init {        select(appSizeRule) {          minHeight = 200.px          minWidth = 300.px        }      }    }

We will create a rule to set the height and width of the application window and store cssclass in companion object so that it can be easily retrieved.

Get Kotlin Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.