arowM/elm-css-modules-helper/1.0.1

CssClass

Provide helper functions to handle CSS modules in Elm without hacks

Types

An opaque type representing transformed class name JSON object generated by CSS modules.

Core functions

decode : Decoder CssClass

Decode CSS transformed class name JSON object to CssClass.

A CssClass value which contains nothing. This value can be used as a default value for failing to decode JSON object.

class : CssClass -> String -> Attribute msg

An alternative function to Html.Attributes.class. This function actually sets a class attribute with value of transformed class name.

e.g., If provided following JSON object and it is decoded as cssClass : CssClass by decode function,

{
  "title": "_title_xkpkl_5 _title_116zl_1",
  "article": "_article_xkpkl_10",
}
CssClasses.class cssClass "title"

This is equivalent to

Html.Attributes.class "_title_xkpkl_5 _title_116zl_1"
classList : CssClass -> List ( String, Bool ) -> Attribute msg

An alternative function to Html.Attributes.classList