aforemny/material-components-web-elm/3.0.3

NOTE: the latest version is 9.1.0

Material.Tab

Tabs organize and allow navigation between groups of content that are related and at the same level of hierarchy. The tab bar contains the tab components.

This module concerns the tab items. If you are looking for information about the tab bar container, refer to Material.TabBar.

Table of Contents

Resources

Basic Usage

import Material.Tab as Tab
import Material.TabBar as TabBar


type Msg
    = TabClicked Int


main =
    TabBar.tabBar TabBar.config
        [ Tab.tab
            (Tab.config
                |> Tab.setActive True
                |> Tab.setOnClick (TabClicked 0)
            )
            { label = "Tab 1", icon = Nothing }
        , Tab.tab
            (Tab.config |> Tab.setOnClick (TabClicked 1))
            { label = "Tab 2", icon = Nothing }
        ]

Configuration

type alias Config msg =
Config msg

Configuration of a tab

config : Config msg

Default configuration of a tab

Configuration Options

setOnClick : msg -> Config msg -> Config msg

Specify a message when the user clicks a tab

setActive : Bool -> Config msg -> Config msg

Specify whether the tab is active

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

Specify additional attributes

Tab

type alias Tab msg =
Tab msg

Tab type

Tabs can only be rendered within a tab bar.

tab : Config msg -> Content -> Tab msg

Tab constructor

type alias Content =
{ label : String
, icon : Maybe String
}

Content of a tab

Active Tab

To mark a tab as active, set its setActive configuration option to True.

Tab.tab (Tab.config |> Tab.setActive True)