List
A List is a vertical arrangement 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 displayed in full. To limit the number of lines, use the headline-line
and description-line
attributes. The maximum limit 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 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>
aligns elements on the left and right. Possible values:
start
: top alignment.center
: center alignment.end
: bottom alignment.
Custom Content
The custom
slot in <mdui-list-item>
allows for full customization of 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 | - | |
Line limit for main text. Truncates after exceeding. Default is no limit. Possible values:
| ||||
description | description | string | - | |
Subtext. Alternatively, use | ||||
description-line | descriptionLine | 1 | 2 | 3 | - | |
Line limit for subtext. Truncates after exceeding. 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. Grays out the item and disables elements like | ||||
active | active | boolean | false | |
Activates the list item. | ||||
nonclickable | nonclickable | boolean | false | |
Makes the list item non-clickable. Elements like | ||||
rounded | rounded | boolean | false | |
Applies rounded style 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 hyperlink. If specified, the component renders as an | ||||
download | download | string | - | |
Instructs the browser to treat the linked URL as a download. Note: This is only available when | ||||
target | target | '_blank' | '_parent' | '_self' | '_top' | - | |
Defines where to display the linked URL. Possible values:
Note: This is 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: This is only available when | ||||
autofocus | autofocus | boolean | false | |
Determines if the element should be focused when the page loads. | ||||
tabindex | tabIndex | number | - | |
Specifies the order in which the element receives focus 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 parameter can be an object with 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 size of the component corner. You can use a specific pixel value, but it's recommended to reference design tokens. |
--shape-corner-rounded |
The size of the component corner when |