aforemny/material-components-web-elm/2.1.1

NOTE: the latest version is 9.1.0

Material.FormField

FormField aligns a form field (for example, a checkbox) with its label and makes it RTL-aware. It also activates a ripple effect upon interacting with the label.

Table of Contents

Resources

Basic Usage

import Material.Checkbox
    exposing
        ( checkbox
        , checkboxConfig
        )
import Material.FormField
    exposing
        ( formField
        , formFieldConfig
        )


main =
    formField { formFieldConfig | label = "My checkbox" }
        [ checkbox checkboxConfig ]

Form Field

formField : FormFieldConfig msg -> List (Html msg) -> Html msg

Form field view function

formFieldConfig : FormFieldConfig msg

Default configuration of a form field

type alias FormFieldConfig msg =
{ label : String
, for : Maybe String
, alignEnd : Bool
, additionalAttributes : List (Attribute msg)
, onClick : Maybe msg
}

Configuration of a form field

Label Position

If you want to position the label after the form field (ie. checkbox), set its alignEnd configuration field to True:

formField { label = "My checkbox", alignEnd = True } [ checkbox checkboxConfig ]