Skip to content

scalajs-react-interface/vdom-styled

Repository files navigation

Build Status Download

vdom-styled

An addon to vdom that provides styled tags.

New styled tags' features:

  1. Type safety. Tags and attributes are objects, which have static types.
  2. Compatible with Intellij IDEA editor. No highlighting error if correct.
  3. Almost no performance penalty. Codes are generated by macro.

Dependency:

"scalajs-react-interface" %%% "vdom" % "version"
"scalajs-react-interface" %%% "vdom-styled" % "version"

How to use:

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.

example:

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.

Complete example

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages