https://github.com/fdietze/formidable
Automatic Form Derivation for Outwatch
https://github.com/fdietze/formidable
outwatch typeclass-derivation typeclasses
Last synced: 5 months ago
JSON representation
Automatic Form Derivation for Outwatch
- Host: GitHub
- URL: https://github.com/fdietze/formidable
- Owner: fdietze
- Created: 2022-04-05T23:30:24.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2025-08-11T12:30:00.000Z (6 months ago)
- Last Synced: 2025-08-25T02:39:40.608Z (5 months ago)
- Topics: outwatch, typeclass-derivation, typeclasses
- Language: Scala
- Homepage:
- Size: 16.3 MB
- Stars: 5
- Watchers: 3
- Forks: 4
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Formidable
Generates reactive HTML forms directly from type definitions. These forms can be used with ScalaJS and [Outwatch](github.com/outwatch/outwatch) and the generated HTML/CSS is fully customizable. Scala 2.13 and 3 are supported. Here's a [Demo](https://fdietze.github.io/formidable) and it's [Code](demo/src/main/scala/Main.scala).
```scala
libraryDependencies += "com.github.fdietze" %%% "formidable" % ""
```
```scala
import outwatch._
import outwatch.dsl._
import colibri.reactive._
import formidable._
case class Person(name: String, age: Option[Int])
val state:Var[Person] = Form.state[Person]
div(
Form[Person].render(state),
div(state.map(_.toString)),
)
```
Formidable defines a typeclass [`Form[T]`](formidable/src/main/scala/Form.scala) with many default instances:
- Primitives: `Int`, `Double`, `Long`, `String`, `Boolean`
- `Option[T]`
- `Seq[T]`, `Vector[T]`, `List[T]`
- sealed traits
- tuples
- case classes
- recursive types
- generic types
Automatic derivation is achieved using [Magnolia](https://github.com/softwaremill/magnolia).