aforemny/material-components-web-elm/2.0.1

NOTE: the latest version is 9.1.0

Material.HelperText

Helper text gives context about a field’s input, such as how the input will be used. It should be visible either persistently or only on focus.

Table of Contents

Resources

Basic Usage

import Material.HelperText exposing (helperText, helperTextConf)
import Material.TextField exposing (textField, textFieldConf)


main =
    Html.div
        [ textField { textFieldConf | label = "Your name" }
        , helperText helperTextConf "Please fill this"
        ]

Helper Text

The helper line is expected to be a direct sibling of the text field it belongs to and the helper text is expected to be a direct child of the helper text line.

helperText : HelperTextConfig msg -> String -> Html msg

Helper text view function

The helper text is expected to be a direct child of the text line.

helperTextConfig : HelperTextConfig msg

Default configuration of a helper text

type alias HelperTextConfig msg =
{ persistent : Bool
, additionalAttributes : List (Attribute msg)
}

Configuration of a helper text

Persistent Helper Text

A text field's helper text may show unconditionally by setting its persistent configuration field to True. By default a text field's helper text only shows when the text field has focus.

Helper Text with Character Counter

To have a text field or text area display a character counter, set its maxLength configuration field, and also add a characterCounter as a child of helperLine.

[ textField
    { textFieldConfig
        | maxLength = Just 18
    }
, helperLine [] [ characterCounter [] ]
]
helperLine : List (Attribute msg) -> List (Html msg) -> Html msg

Helper text line view function

The text line is expected to be the wrapping element of the helper text. It is expected to be a direct sibling of the text field that it belongs to.

characterCounter : List (Attribute msg) -> Html msg

Character counter view function