List
Directives for creating material designed lists and list-groups.
API
Directive: MdcListDividerDirective
Selector: [mdcListDivider]
Directive for a separator in a list (between list items), or as a separator in a list group (between lists).
Accessibility
This directive adds a role=separator attribute when it is used as a separator
between list items.
| Property | Description |
|---|---|
@Input()
inset
boolean
|
When this input is defined and does not have value false, the divider is styled with an inset. |
@Input()
padded
boolean
|
When this input is defined and does not have value false, the divider leaves
gaps on each site to match the padding of |
Directive: MdcListItemDirective
Selector: [mdcListItem]
Directive for the items of a material list.
This directive should be used for the direct children (list items) of an
mdcList.
Children
- Use
mdcListItemTextfor the text content of the list. One line and two line lists are supported. SeemdcListItemTextfor more info. - Optional:
mdcListItemGraphicfor a starting detail (typically icon or image). - Optional:
mdcListItemMetafor the end detail (typically icon or image).
Accessibility
- All items in a list will get a
tabindex=-1attribute to make them focusable, but not tabbable. The focused, active/current, or first (in that preference) item will gettabindex=0, so that the list can be tabbed into. Keyboard navigation between list items is done with arrow, home, and end keys. Keyboard based selection of an item (when items are selectable), can be done with the enter or space key. - The
roleattribute with be set tooptionfor single selection lists,checkboxfor list items that can be selected with embedded checkbox inputs,radiofor for list items that can be selected with embedded radio inputs,menuitemwhen the list is part of anmdcMenu. Otherwise there will be noroleattribute, so the default role for a standard list item (role=listitem) will apply. - Single selection lists set the
aria-selectedoraria-currentattributes, based on the chosenselectionModeof the list. Please see WAI-ARIA aria-current for recommendations. aria-checkedwill be set for lists with embedded checkbox or radio inputs.- Disabled list items will be included in the keyboard navigation. This follows
focusability of disabled controls
recommendations in the ARIA practices article. Exception: when the list is part of an
mdcMenuormdcSelect, disabled items are not included in the keyboard navigation. - As the user navigates through the list, any button and anchor elements within list items that are not focused
will receive
tabindex=-1. When the list item receives focus, those elements will receivetabindex=0. This allows for the user to tab through list item elements and then tab to the first element after the list. - Lists are interactive by default (unless
nonInteractiveis set on themdcList). List items will show ripples when interacted with. aria-disabledwill be set for disabled list items. When the list uses checkbox or radio inputs to control the checked state, the disabled state will mirror the state of those inputs.
| Property | Description |
|---|---|
@Output()
action
EventEmitter<void>
|
Event emitted for user action on the list item, including keyboard and mouse actions.
This will not emit when the |
@Output()
selectedChange
EventEmitter<boolean>
|
Event emitted when the active state of a list item in a single-selection list
( |
@Input()
disabled
boolean
|
If set to a value other than false, the item will be disabled. This affects styling and selectability, and may affect keyboard navigation. This input is ignored for lists where the selection is controlled by embedded checkbox or radio inputs. In those cases the disabled state of the input will be used instead. |
@Input()
value
string
|
Assign this field with a value that should be reflected in the |
@Input()
selected
boolean
|
This input can be used to change the active or selected state of the item. This should not be used for lists
inside an |
Directive: MdcListItemTextDirective
Selector: [mdcListItemText]
Directive to mark the text portion(s) of an mdcListItem. This directive should be the child of an mdcListItem.
For single line lists, the text can be added directly to this directive.
For two line lists, add mdcListItemPrimaryText and mdcListItemSecondaryText children.
Directive: MdcListItemPrimaryTextDirective
Selector: [mdcListItemPrimaryText]
Directive to mark the first line of an item with "two line list" styling.
This directive, if used, should be the child of an mdcListItemText.
Using this directive will put the list "two line" mode.
Directive: MdcListItemSecondaryTextDirective
Selector: [mdcListItemSecondaryText]
Directive for the secondary text of an item with "two line list" styling.
This directive, if used, should be the child of an mdcListItemText, and
come after the mdcListItemPrimaryText.
Directive: MdcListItemGraphicDirective
Selector: [mdcListItemGraphic]
Directive for the start detail item of a list item.
This directive, if used, should be the child of anmdcListItem.
Directive: MdcListItemMetaDirective
Selector: [mdcListItemMeta]
Directive for the end detail item of a list item.
This directive, if used, should be the child of an mdcListItem.
Directive: MdcListDirective
Selector: [mdcList]
Lists are continuous, vertical indexes of text or images. They can be interactive, and may support
selaction/activation of list of items. Single-line and Two-line lists are supported, as well as
starting and end details (images or controls) on a list. A list contains mdcListItem children,
and may also contain mdcListDivider children.
A list can be used by itself, or contained inside mdcListGroup, mdcMenu, or mdcSelect.
Accessibility
- See Accessibility section of
mdcListItemfor navigation, focus, and tab(index) affordances. - The
roleattribute will be set tolistboxfor single selection lists (selectionModeissingleoractive), toradiogroupwhen selection is triggered by embedded radio inputs, tocheckboxwhen selection is triggered by embedded checkbox inputs, tomenuwhen used insidemdcMenu. Otherwise there will be noroleattribute, so the default role for a standard list (role=list) will apply. - You should set an appropriate
labelfor checkbox based selection lists. Thelabelwill be reflected to thearia-labelattribute.
| Property | Description |
|---|---|
@Input()
dense
boolean
|
When this input is defined and does not have value false, the list will be styled more compact. |
@Input()
selectionMode
"single" | "active"
|
When set to When using The selectionMode is ignored when there are embedded checkbox or radio inputs inside the list, in which case those inputs will trigger selection of list items. |
@Input()
nonInteractive
boolean
|
When this input is defined and does not have value false, the list will be made non-interactive. Users will not be able to interact with list items, and the styling will reflect this (e.g. by not adding ripples to the items). |
@Input()
wrapFocus
boolean
|
When this input is defined and does not have value false, focus will wrap from last to first and vice versa when using keyboard navigation through list items. |
@Input()
avatarList
boolean
|
When this input is defined and does not have value false, elements with directive |
Directive: MdcListGroupSubHeaderDirective
Selector: [mdcListGroupSubHeader]
Directive for a header inside a list group (mdcListGroup) directive.
Directive: MdcListGroupDirective
Selector: [mdcListGroup]
Directive for a material designed list group, grouping several mdcList lists.
List groups should contain elements with mdcListGroupSubHeader,
and mdcList directives. Lists may be separated by mdcListSeparator directives.