An addon to vdom that provides styled tags.
- Type safety. Tags and attributes are
object
s, which have static types. - Compatible with Intellij IDEA editor. No highlighting error if correct.
- Almost no performance penalty. Codes are generated by macro.
"scalajs-react-interface" %%% "vdom" % "version"
"scalajs-react-interface" %%% "vdom-styled" % "version"
import sri.web.styledtagsPrefix_<^._ //recommended for avioding name conflicts.
//tags begin with `<`, attributes begin with `^`
//or
import sri.web.styledtags._
//you still have type safety.
import sri.core._
import sri.web.styledtagsPrefix_<^._
<.div()("Only contents.")
<.div(^.value := "some value")("Contents with value")
<.div()(
"Has child:",
<.p(^.value := "v1")("I'm a child <p>")
)
<.a(
^.onClick := ((e: ReactEventI) => println("this is a callback"))
)("Click me will log something.")
//note := is a method, when pass complicated code in, you need give them parentheses.