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 Scroller and Tab components.
import Material.TabBar
exposing
( tab
, tabBar
, tabBarConfig
, tabConfig
)
type Msg
= TabClicked Int
main =
tabBar tabBarConfig
[ tab
{ tabConfig
| active = True
, onClick = Just (TabClicked 0)
}
{ label = "Tab 1", icon = Nothing }
, tab
{ tabConfig
| active = False
, onClick = Just (TabClicked 1)
}
{ label = "Tab 1", icon = Nothing }
]Default configuration of a tab bar
Configuration of a tab bar
Default configuration of a tab
Configuration of a tab
Content of a tab
Tab
In a stacked tab bar, the label and icon of a tab flow vertically instead of
horizontally. To make a tab bar stacked, set its stacked configuration
field to True.
Requires that the tabs have both label and icon.
tabBar
{ tabBarConfig | stacked = True }
[ tab tabConfig
{ label = "Favorites", icon = Just "favorite" }
]Tabs by defauls span a minimum width. If you want tabs to be as narrow as
possible, set the tab bar's minWidth configuration field to True.
tabBar
{ tabBarConfig | minWidth = True }
[ tab tabConfig
{ label = "Favorites", icon = Nothing }
]The tab's active indicator by default spans the entire tab. If you want active
indicators to only span their tab's content, set the tab bar's
indicatorSpansContent configuration field to True.
tabBar
{ tabBarConfig | indicatorSpansContent = True }
[ tab tabConfig
{ label = "Favorites", icon = Nothing }
]The tab bar supports tabs overflowing its width and will enable scrolling in that case. You may change the alignment of the elements inside the scroll content.
Configuration of a tab scroller
Default configuration of a tab scroller
Alignment of a tab scroller
tabBar
{ tabBarConfig
| tabScrollerConfig =
{ tabScrollerConfig
| align =
Just TabBar.TabScrollerAlignCenter
}
}
[ tab
{ tabConfig
| active = True
, onClick = Just (TabClicked 0)
}
{ label = "Tab 1", icon = Nothing }
, tab
{ tabConfig
| active = False
, onClick = Just (TabClicked 1)
}
{ label = "Tab 1", icon = Nothing }
]
Tab bar view function