Lists are continuous, vertical indexes of text or images.
This module concerns the container list. If you are looking for information about the list items, refer to Material.List.Item.
import Material.List as List
import Material.List.Item as ListItem
main =
List.list List.config
[ ListItem.listItem ListItem.config
[ text "Line item" ]
, ListItem.listItem ListItem.config
[ text "Line item" ]
]Specify whether a list should be non-interactive
Non-interactive lists do not feature keyboard interaction and list items have no visual interaction effect.
Specify whether a list should be dense
Dense lists are more compact and feature smaller than normal margins
Specify whether a list should be an avatar list
An avatar list features a larger than usual list item graphic.
Specify whether a list should be a two line list
Two line lists feature list items with a primary and a secondary text line.
Specify additional attributes
Specify whether a list should wrap focus
A list that wraps focus focuses the first list item after pressing tab on the last list item. By default, a list in that case passes focus to the next focusable control.
Lists may be two-line lists by setting its setTwoLine configuration option
to True. In that case, list items should wrap their contents inside
ListItem.text.
List.list (List.config |> List.setTwoLine True)
[ ListItem.listItem ListItem.config
[ ListItem.text []
{ primary = [ text "First line" ]
, secondary = [ text "Second line" ]
}
]
]Lists may be non-interactive by its setting setNonInteractive configuration
option to True.
Non-interactive lists do not feature keyboard interaction and list items have no visual interaction effect.
List.list
(List.config |> List.setNonInteractive True)
[ ListItem.listItem ListItem.config [ text "List item" ]
]Lists may be styled more compact by setting its setDense configuration option
to True.
Dense lists feature smaller than normal margins.
List.list
(List.config |> List.setDense True)
[ ListItem.listItem ListItem.config [ text "List item" ]
]A list item's graphics may be configured to appear larger by setting its
setAvatarList configuration option to True.
List.list
(List.config |> List.setAvatarList True)
[ ListItem.listItem ListItem.config
[ ListItem.graphic [] [ Html.img [] [] ]
, text "List item"
]
]Multiple related lists, such as folders and files in a file hierarchy, may be
grouped using group and labeled by subheader.
List.group []
[ List.subheader [] [ text "Folders" ]
, List.list List.config
[ ListItem.listItem ListItem.config [ text "Folder" ]
, ListItem.listItem ListItem.config [ text "Folder" ]
]
, List.subheader [] [ text "Files" ]
, List.list List.config
[ ListItem.listItem ListItem.config [ text "File" ]
, ListItem.listItem ListItem.config [ text "File" ]
]
]List group view function
List group subheader view function
You may programatically focus a list by assigning an id attribute to it and use
Browser.Dom.focus.
List.list
(List.config
|> List.setAttributes
[ Html.Attributes.id "my-list" ]
)
[ ListItem.listItem ListItem.config [ text "Line item" ]
]
Configuration of a list