proda-ai / elm-svg-loader / InlineSvg

This library allows you to inline external SVG file into Elm views.

inline : icons -> Helpers icons msg

This function returns a record, which contains a icon function to reference individual SVG document.

{ icon } =
    inline
        { github = "./svg/github.svg"
        , share = "./svg/share.svg"
        }

view =
    div
        []
        [ icon .github [ Svg.Attributes.class "icon icon--github" ]
        , icon .share [ Svg.Attributes.class "icon icon--share" ]
        ]


type alias Helpers icons msg =
{ icon : (icons -> String) -> List (Svg.Attribute msg) -> Html msg }

This is the record returned from inline function. icon function is used to access individual SVG document, you can also pass a list of attributes to the SVG.

icon .share [Svg.Attributes.fill "blue"] : Html msg