Andrew
Andrew

Reputation: 1320

Elm The Html.Attributes module does not expose css

Elm cannot find css for some reason

import Html.Attributes exposing (class, css)

enter image description here

elm.json:

{
    "type": "application",
    "source-directories": [
        "src"
    ],
    "elm-version": "0.19.1",
    "dependencies": {
        "direct": {
            "elm/browser": "1.0.2",
            "elm/core": "1.0.5",
            "elm/html": "1.0.0",
            "matheus23/elm-default-tailwind-modules": "2.0.3",
            "rtfeldman/elm-css": "17.0.5"
        },
        "indirect": {
            "elm/json": "1.1.3",
            "elm/time": "1.0.0",
            "elm/url": "1.0.0",
            "elm/virtual-dom": "1.0.2",
            "robinheghan/murmur3": "1.0.0",
            "rtfeldman/elm-hex": "1.0.0"
        }
    },
    "test-dependencies": {
        "direct": {},
        "indirect": {}
    }
}

Upvotes: 1

Views: 283

Answers (1)

Jack Leow
Jack Leow

Reputation: 22477

css isn't part of the core Elm Html.Attribute module, it's part of elm-css (which I see you've included in your elm.json), which introduces the Html.Styled, Html.Styled.Attributes, Html.Styled.Events modules that are basically drop-in replacements for their non-Styled counterparts, but with css support.

So just change:

import Html.Attributes exposing (class, css)

To:

import Html.Styled.Attributes exposing (class, css)

And you should be good.

For details, see their docs - https://package.elm-lang.org/packages/rtfeldman/elm-css/17.0.5/

Upvotes: 6

Related Questions