Html.Attributes

HTML & web

HTML attributes for server-rendered elements. String attributes (class, id, href, src, type_, ...), boolean attributes (disabled, checked, hidden, ...), and integer attributes (height, width, tabindex, ...). type_ / for_ avoid reserved words.

Types

Attribute

type Attribute msg = Attribute

An HTML attribute parameterized by a message type.

Examples

title : Attribute msg
title =
    attribute "title" "Selm"

Values

attribute

attribute : String -> String -> Attribute msg

A raw name/value attribute.

Examples

attribute "data-id" "42"

style

style : String -> String -> Attribute msg

An inline CSS style declaration.

Examples

style "color" "navy"

map

map : (a -> b) -> Attribute a -> Attribute b

Remap the message type of an attribute.

Examples

map Never (attribute "id" "main")

classList

classList : List (String, Bool) -> Attribute msg

Build a class attribute from (name, enabled) pairs.

Examples

classList [ ("active", True), ("hidden", False) ]