aforemny/material-components-web-elm/6.0.0

NOTE: the latest version is 9.1.0

Rerouted (regenerated, verified). Same repository and tag, but GitHub now builds the zip with different bytes, so it no longer matches the SHA-1 package.elm-lang.org recorded. The Lamdera package server serves a copy recovered from https://github.com/aforemny/material-components-web-elm.

What we checked: Tag 6.0.0 is still on github.com/aforemny/material-components-web-elm; its commit fa5f16f0eddc is from 2020-10-08 13:01 UTC, before the version was published (2020-10-08 13:03 UTC); every file Elm uses matches a copy in a Lamdera package cache from 2021-02-13, from before the change; elm.json is byte-identical to package.elm-lang.org's; the exposed modules match docs.json; the zip's SHA-1 is not the published one (GitHub's zip no longer comes out byte for byte the same), so the contents were checked instead.

The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.

Details · package.elm-lang.org's zip: https://github.com/aforemny/material-components-web-elm/zipball/6.0.0/

Material.TextArea

Text areas allow users to input, edit, and select multiline text.

Table of Contents

Resources

Basic Usage

import Material.TextArea as TextArea


type Msg
    = ValueChanged String


main =
    TextArea.filled
        (TextArea.config
            |> TextArea.setLabel (Just "My text area")
            |> TextArea.setValue (Just "hello world")
            |> TextArea.setOnInput ValueChanged
            |> TextArea.setRows (Just 4)
            |> TextArea.setCols (Just 20)
        )

Configuration

type Config msg

Configuration of a text area

Default configuration of a text area

Configuration Options

setOnInput : (String -> msg) -> Config msg -> Config msg

Specify a message when the user changes the value inside the text area

setOnChange : (String -> msg) -> Config msg -> Config msg

Specify a message when the user confirms a changed value inside the text area

setLabel : Maybe String -> Config msg -> Config msg

Specify a text area's label

setFullwidth : Bool -> Config msg -> Config msg

Specify a text area to be fullwidth

setValue : Maybe String -> Config msg -> Config msg

Specify a text area's value

setPlaceholder : Maybe String -> Config msg -> Config msg

Specify a text area's placeholder

setRows : Maybe Int -> Config msg -> Config msg

Specify a text area's number of rows

setCols : Maybe Int -> Config msg -> Config msg

Specify a text area's number of columns

setDisabled : Bool -> Config msg -> Config msg

Specify a text area to be disabled

Disabled text areas cannot be interacted with and have no visual interaction effect.

setRequired : Bool -> Config msg -> Config msg

Specify a text area to be required

setValid : Bool -> Config msg -> Config msg

Specify a text area to be valid

setMinLength : Maybe Int -> Config msg -> Config msg

Specify a text area's minimum length

setMaxLength : Maybe Int -> Config msg -> Config msg

Specify a text area's maximum length

setAttributes : List (Attribute msg) -> Config msg -> Config msg

Specify additional attributes

Filled Text Area

TextArea.filled TextArea.config
filled : Config msg -> Html msg

Filled text area view function

Outlined Text Area

Text areas may have a visible outlined around them by using their outlined variant.

TextArea.outlined TextArea.config

Note that setFullwidth does not have any effect on an outlined text area.

outlined : Config msg -> Html msg

Outlined text area view function

Full Width Text Area

To make a text area span all of its available width, set its setFullwidth configuration option to True.

TextArea.filled
    (TextArea.config |> TextArea.setFullwidth True)

Full width text areas do not support labels and will ignore the setLabel configuration option. You may use setPlaceholder or provide an extraneous label for a full width text area.

Outlined text areas do not support setFullwidth and will ignore this configuration option.

Disabled Text Area

To disable a text area, set its setDisabled configuration option to True.

TextArea.filled
    (TextArea.config |> TextArea.setDisabled True)

Required Text Area

To mark a text area as required, set its setRequired configuration option to True.

TextArea.filled
    (TextArea.config |> TextArea.setRequired True)

Valid Text Area

To mark a text area as valid, set its setValid configuration option to True.

TextArea.filled (TextArea.config |> TextArea.setValid True)

Text Area with Character Counter

To have a text area display a character counter, specify its setMaxLength configuration option, and also add a HelperText.characterCounter as a child of HelperText.helperLine.

[ TextArea.filled
    (TextArea.config |> TextArea.setMaxLength (Just 18))
, HelperText.helperLine [] [ HelperText.characterCounter [] ]
]

Focus a Text Area

You may programatically focus a text area by assigning an id attribute to it and use Browser.Dom.focus.

TextArea.filled
    (TextArea.config
        |> TextArea.setAttributes
            [ Html.Attributes.id "my-text-area" ]
    )