Card
Cards are versatile components that serve as containers for content and actions about 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 will add hover and click ripple effects.
Link
Use the href
attribute to transform 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 style. Possible values:
| ||||
clickable | clickable | boolean | false | |
Makes the card clickable. When set, a mouse hover effect and click ripple effect are added. | ||||
disabled | disabled | boolean | false | |
Disables the card. | ||||
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. |
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. |