KVision - Object oriented Web UI framework for Kotlin/JS



I’ve just published KVision - a new open source framework for building web applications in Kotlin. It’s available at https://github.com/rjaros/kvision.

KVision gives you a hierarchy of many different components, which are used to build application UI. It integrates many JavaScript, CSS and Kotlin-based components and projects (Bootstrap, Snabbdom, Font awesome, Trix editor, Kotlin observables and others) to give you an uniform working environment.

Additional information, examples and API documentation is available from the GitHub page.

I appreciate any comments and feedback.



At a first glance it is more mature then the one presented here few days ago.
The problem I see here is the lack of kotlin-style builders. Code like that:

        val mainPanel = HPanel(wrap = FLEXWRAP.WRAP, spacing = 100)
        val buttonsPanel = VPanel(spacing = 7)
        buttonsPanel.add(Button("Default button", style = BUTTONSTYLE.DEFAULT).apply { width = 200.px() })
        buttonsPanel.add(Button("Primary button", style = BUTTONSTYLE.PRIMARY).apply { width = 200.px() })
        buttonsPanel.add(Button("Success button", style = BUTTONSTYLE.SUCCESS).apply { width = 200.px() })
        buttonsPanel.add(Button("Info button", style = BUTTONSTYLE.INFO).apply { width = 200.px() })
        buttonsPanel.add(Button("Warning button", style = BUTTONSTYLE.WARNING).apply { width = 200.px() })
        buttonsPanel.add(Button("Danger button", style = BUTTONSTYLE.DANGER).apply { width = 200.px() })
        buttonsPanel.add(Button("Link button", style = BUTTONSTYLE.LINK).apply { width = 200.px() })

looks ugly in kotlin. It could easily be reduced with apply block. Also with a little effort, one could add builder functions, which could make the API much more comprehensible. Like that:

class VPanel(...){

  fun button(title: String, ..., op: (Button) -> Unit){
    this.add(Button(title, ... ).apply (op))

and then, voila:

val buttonsPanel = vpanel(spacing = 7){
  button(("Default button",...){}
  button("Primary button",...){}
  button("Success button",...){}

In my opinion, you should look into tornadofx implementation. Maybe even see if you could use similar syntax.


Thanks for your feedback!
I’ve published version 0.0.3 with new DSL builders for all containers and components. The builders are made with extension functions so it is even possible to write such functions for new, custom components.
I’ve refactored examples to use these kotlin-style builders, too.


@rjaros I had a look at the examples and I really liked it. I find JS a bit chaotic. Do you thin it is possible to use KVision to write a single page JS REST client that requests and responds in json from and to different endpoints over HTTPS? I guess it would also need some notion of state and routing.


It’s definitely possible. At the moment KVision doesn’t have any dedicated methods to call REST endpoints, but it has integrated jQuery bindings and some helper extension functions as well. So you can simply write:

jQuery.post("/rest_url", mapOf("key1" to "value1", "key2" to "value2").asJson(), { data, status, xhr ->


OK. Is there plans for dedicated methods to call REST endpoint?. I like to stay away from JS as much as possible :slight_smile: even though the current approach doesn’t look to overwhelming.


I plan to add dedicated api for remote endpoints, but first I have to think it through. I would like it to be as optimal as possible to use and I have to learn more about coroutines and promises :slight_smile:


Cool, thanks. I’ll keep an eye on this post :wink:


Would it be possible to use the DSL to compile the layout to JavaFX GUIs? Is there such a cross-platform toolkit?