Helper functions for using elm-css with elm-html.
Prepend the given class name to a Html.node function's attributes list.
import Html exposing (Html, Attribute, text)
import Html.Attributes exposing (class)
import Html.CssHelpers exposing (withClass)
{-| Create a `button` variant that automatically includes a "warning" class.
-}
warningButton : List (Attribute msg) -> List (Html msg) -> Html msg
warningButton =
withClass "warning" button
confirmDeleteButton : Html msg
confirmDeleteButton =
-- Equivalent to:
--
-- button [ class "warning" ] [ text "Confirm Deletion" ]
warningButton [] [ text "Confirm Deletion" ]Since class attributes "stack" in Elm (e.g.
button [ class "warning", class "centered" ] [] is equivalent to
button [ class "warning centered" ] []), this API permits further
customization on a per-instance basis, either by using the style attribute
or by stacking additional classes
(for example warningButton [ class "centered" ] []).
Create an inline style from CSS
Link in a stylesheet from a url
Helpers for working on a given class/id
namespaced helpers for working on a given class/id
Takes a namespace and returns helper functions for
id,class, andclassListwhich work just like their equivalents inelm-htmlexcept that they accept union types and automatically incorporate the given namespace. Also note thatclassaccepts aListinstead of a single element; this is so you can specify multiple classes without having to callclassListpassing tuples that all end inTrue.The above would generate this DOM element: