aforemny/material-components-web-elm/3.0.1

NOTE: the latest version is 9.1.0

Material.Radio

Radio buttons allow the user to select one option from a set while seeing all available options.

Table of Contents

Resources

Basic Usage

Note that radio buttons are usually used in conjunction with form fields.

import Material.Radio as Radio


type Msg
    = Changed


main =
    Radio.radio
        (Radio.config
            |> Radio.setChecked True
            |> Radio.setOnChange Changed
        )

Configuration

type Config msg

Radio button configuration

Default radio button configuration

Configuration Options

setOnChange : msg -> Config msg -> Config msg

Specify a message when the user changes a radio

setChecked : Bool -> Config msg -> Config msg

Specify whether a radio button is checked

setDisabled : Bool -> Config msg -> Config msg

Specify whether a radio button is disabled

Disabled radio buttons cannot be interacted with and have no visual interaction effect.

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

Specify additional attributes

Radio

radio : Config msg -> Html msg

Radio button view function

Checked Radio

To make a radio button display its checked state, set its setChecked configuration option to True.

Radio.radio (Radio.config |> Radio.setChecked True)

Disabled Radio

To disable a radio button, set its setDisabled configuration option to True.

Disabled radio buttons cannot be interacted with and have no visual interaction effect.

Radio.radio (Radio.config |> Radio.setDisabled True)