Quick Start

You can use this starter repo to get you up and running!
Just clone it and then:

  • run sbt
  • run client/fastOptJS in it
  • open client/index.html

Basics

RxTags uses ScalaTags library behind the scenes, so it is very useful to be familiar with it.
It is pretty simple library for building HTML, similar to JSX.
A big difference is that it is just Scala, no special preprocessor needed.

Let's see an example:


        import scalatags.JsDom.all._
        
        val number = 123

        def content = div(
          h4("ScalaTags example"),
          footer(cls := "abc")(
            s"Hello, visitor number: $number"
          )
        )
      

We can see that div is just a simple function call.
It gets children HTML tags passed as parameters.
ScalaTags calls these visible parts Frags, fragments.

Attributes are assigned with the := operator.

We can use arbitrary Scala code, like string interpolation in our example.
Feel free to use lists and map them to HTML, use helper functions, classes etc.

Then we will use ScalaJS to attach that ScalaTags snippet as a real DOM node:


        val root = dom.document.getElementById("root")
        root.appendChild(content.render)
      
Result: