rtfeldman / elm-css

Typed CSS in Elm.
https://package.elm-lang.org/packages/rtfeldman/elm-css/latest
BSD 3-Clause "New" or "Revised" License
1.24k stars 197 forks source link

Cannot use elm-css with lamdera #540

Open hiovi opened 3 years ago

hiovi commented 3 years ago

I'm quite new to elm. I was wondering if I could use elm-css with lamdera. Has anyone tried it?

Strepto commented 3 years ago

This should work fine.

See attached example for how to setup elm-css with lamdera.

First install elm-css through lamdera.

lamdera install rtfeldman/elm-css

Then modify your Frontend.elm file (as of Lamdera 1.0)


-- Additional Imports
import Css
import Css.Global
import Html.Styled as Html exposing (..)
import Html.Styled.Attributes as Attr

-- Remove existing Html imports

-- snip

-- snip

view : Model -> Browser.Document FrontendMsg
view model =
    { title = ""
    , body =
        [ Html.toUnstyled <|
            Html.div [ Attr.css [ Css.backgroundColor (Css.rgb 100 255 100) ] ]
                [  text "Hello World!"
                ]
        ]
    }