List
A list is a vertical collection of items that can contain text or images.
Usage
Import the component:
import 'mdui/components/list.js';
import 'mdui/components/list-item.js';
import 'mdui/components/list-subheader.js';
Import the TypeScript type:
import type { List } from 'mdui/components/list.js';
import type { ListItem } from 'mdui/components/list-item.js';
import type { ListSubheader } from 'mdui/components/list-subheader.js';
Example:
<mdui-list>
<mdui-list-subheader>Subheader</mdui-list-subheader>
<mdui-list-item>Item 1</mdui-list-item>
<mdui-list-item>Item 2</mdui-list-item>
</mdui-list>Examples
Text Content
The headline attribute on <mdui-list-item> sets the primary text, while the description attribute sets the secondary text.
Alternatively, use the default slot for the primary text and the description slot for the secondary text.
By default, both primary and secondary text are shown in full. To limit the number of lines, use the headline-line and description-line attributes. The maximum is 3 lines.
Side Content
The icon and end-icon attributes on <mdui-list-item> add Material Icons to the left and right sides, respectively.
Alternatively, use the icon and end-icon slots to add elements to the left and right sides of the list item.
Link
The href attribute turns the list item into a link, with download, target, and rel attributes available for link-related functionality.
Disabled State
The disabled attribute on <mdui-list-item> disables the item. This also disables components within the list item.
Active State
The active attribute on <mdui-list-item> activates the item.
Nonclickable State
The nonclickable attribute on <mdui-list-item> removes mouse hover and click ripple effects.
Rounded Shape
The rounded attribute on <mdui-list-item> gives the item a rounded appearance.
Vertical Alignment
The alignment attribute on <mdui-list-item> controls the vertical alignment of side elements. Possible values:
start: align to the top.center: center aligned.end: align to the bottom.
Custom Content
The custom slot in <mdui-list-item> lets you fully customize the list item content.
mdui-list-item API
Properties
| Attribute | Property | Reflect | Type | Default |
|---|---|---|---|---|
headline | headline | string | - | |
Main text. Alternatively, use the default slot. | ||||
headline-line | headlineLine | 1 | 2 | 3 | - | |
Maximum number of lines for the main text. Overflow text is truncated. Default is no limit. Possible values:
| ||||
description | description | string | - | |
Subtext. Alternatively, use | ||||
description-line | descriptionLine | 1 | 2 | 3 | - | |
Maximum number of lines for the subtext. Overflow text is truncated. Default is no limit. Possible values:
| ||||
icon | icon | string | - | |
Material Icons name on the left. Alternatively, use | ||||
end-icon | endIcon | string | - | |
Material Icons name on the right. Alternatively, use | ||||
disabled | disabled | boolean | false | |
Disables the list item. It dims the item and disables interactive elements like | ||||
active | active | boolean | false | |
Marks the list item as active. | ||||
nonclickable | nonclickable | boolean | false | |
Disables the list item's default click action, but interactive elements like | ||||
rounded | rounded | boolean | false | |
Applies a rounded appearance to the list item. | ||||
alignment | alignment | 'start' | 'center' | 'end' | 'center' | |
Vertical alignment of the list item. Possible values:
| ||||
href | href | string | - | |
The URL for the link. When set, the component renders as an | ||||
download | download | string | - | |
Downloads the linked URL. Note: Only available when | ||||
target | target | '_blank' | '_parent' | '_self' | '_top' | - | |
Controls where the linked URL opens. Possible values:
Note: Only available when | ||||
rel | rel | 'alternate' | 'author' | 'bookmark' | 'external' | 'help' | 'license' | 'me' | 'next' | 'nofollow' | 'noreferrer' | 'opener' | 'prev' | 'search' | 'tag' | - | |
Specifies the relationship of the linked URL as space-separated link types. Possible values:
Note: Only available when | ||||
autofocus | autofocus | boolean | false | |
Whether the element is focused when the page loads. | ||||
tabindex | tabIndex | number | - | |
The element's tab order when navigating with the Tab key. | ||||
Methods
| Name | Parameters | Returns |
|---|---|---|
click | void | |
Simulates a mouse click on the element. | ||
focus |
| void |
Sets focus on the element. An optional object parameter may include a | ||
blur | void | |
Removes focus from the element. | ||
Slots
| Name |
|---|
| (default) |
Main text. |
description |
Subtext. |
icon |
Element on the left of the list item. |
end-icon |
Element on the right of the list item. |
custom |
Any custom content. |
CSS Custom Properties
| Name |
|---|
--shape-corner |
The corner radius of the component. You can use a specific pixel value, but it is recommended to reference design tokens. |
--shape-corner-rounded |
The corner radius of the component when |