web-view is a library for type-safe HTML and CSS with intuitive layouts and composable styles. This is an idea I’ve been experimenting with for a few years, and I’m happy to finally release it! I’ve used this approach on multiple professional projects, and it is currently being used at the National Solar Observatory. It combines the best ideas of Tailwindcss and Elm-UI with Haskell.
myPage = col (gap 10) $ do
el (bold . fontSize 32) "My page"
button (border 1) "Click Me"
Instead of relying on CSS’s poor programming features, we can use normal Haskell functions to factor and reuse our app’s styles
header = bold
h1 = header . fontSize 32
h2 = header . fontSize 24
page = gap 10
myPage = col page $ do
el h1 "My Page"
...
It has more features, including
- Intuitive Layouts with
row
,col
,grow
andspace
- Embedded page-specific CSS
- Stateful styles (like hover) and responsive designs
Any and all questions or feedback welcome! The reasoning behind using utility classes for CSS is explained well here. Also, stay tuned in the coming weeks for the upcoming release of Hyperbole, a server-only interactive web-framework that leverages this library.