Tabs
Together, tabList, tab, and tabPanel describe the pieces of a tab component view.
import Accessibility exposing (Html, tab, tabList, tabPanel, text)
import Accessibility.Aria exposing (controls, labelledBy)
import Accessibility.Widget exposing (hidden, selected)
import Html.Attributes exposing (id)
view : Html msg
view =
tabList
[ id "tab-list" ]
[ tab
[ id "tab-1"
, selected True
, controls "panel-1"
]
[ text "Tab One" ]
, tab
[ id "tab-2"
, selected False
, controls "panel-2"
]
[ text "Tab Two" ]
, tabPanel
[ id "panel-1"
, labelledBy "tab-1"
, hidden False
, Html.Attributes.hidden False
]
[ text "Panel One Content" ]
, tabPanel
[ id "panel-2"
, labelledBy "tab-2"
, hidden True
, Html.Attributes.hidden True
]
[ text "Panel Two Content" ]
]
For a more fully-fledged example using these helpers check out elm-tabs.
All inputs must be associated with a
<label>tag. Here is an example that creates a text input for first names:Now if you said
firstNameInput "Tom"you would get HTML like this: