Card
Cards are versatile components that hold content and actions for a single subject.
Usage
Import the component:
import 'mdui/components/card.js';
Import the TypeScript type:
import type { Card } from 'mdui/components/card.js';
Example:
<mdui-card style="width: 200px;height: 124px">Card</mdui-card>Clickable
Add the clickable attribute to make the card interactive. This adds hover and click ripple effects.
Link
Use the href attribute to turn the card into a link. The download, target, and rel attributes are available for link-related functionality.
Disabled State
Use the disabled attribute to disable the card.
API
Properties
| Attribute | Property | Reflect | Type | Default |
|---|---|---|---|---|
variant | variant | 'elevated' | 'filled' | 'outlined' | 'elevated' | |
Defines the card variant. Possible values:
| ||||
clickable | clickable | boolean | false | |
Makes the card clickable. If set, hover and click ripple effects are added. | ||||
disabled | disabled | boolean | false | |
Disables the card. | ||||
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. | ||
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. |