aforemny/material-components-web-elm/1.0.0

NOTE: this package is not compatible with Elm 0.19.1

Material.Checkbox

Checkboxes allow the user to select one or more items from a set.

Table of Contents

Resources

Basic Usage

Note that checkboxes are usually used in conjunction with form fields. Refer to FormField for more information.

import Material.Checkbox as Checkbox
    exposing
        ( checkbox
        , checkboxConfig
        )


type Msg
    = CheckboxClicked


main =
    checkbox
        { checkboxConfig
            | state = Checkbox.Unchecked
            , onClick = Just CheckboxClicked
        }

Checkbox

checkbox : CheckboxConfig msg -> Html msg

Checkbox view function

checkboxConfig : CheckboxConfig msg

Default configuration of a checkbox

type alias CheckboxConfig msg =
{ state : CheckboxState
, disabled : Bool
, additionalAttributes : List (Attribute msg)
, onClick : Maybe msg
}

Configuration of a checkbox

= Unchecked
| Checked
| Indeterminate

Checked Checkbox

To set the state of a checkbox to checked, set its state configuration field to Checked. To set its state to unchecked, use Unchecked.

checkbox { checkboxConfig | state = Checkbox.Checked }

Indeterminate Checkbox

To set the state of a checkbox to indeterminate, set its state configuration field to Indeterminate.

checkbox
    { checkboxConfig | state = Checkbox.Indeterminate }

Disabled Checkbox

To disable a checkbox, set its disabled configuration field to True. Disabled checkboxes cannot be interacted with and have no visual interaction effect.

checkbox { checkboxConfig | disabled = True }