MDUIDocs
Copy llms.txt linkCopy llms-full.txt linkView this page in MarkdownDiscuss this page with ChatGPTDiscuss full project docs with ChatGPT
Preset Colors
Custom Color
Extract from Wallpaper
Please select a wallpaper
Getting Started
AI-Assisted Development
Styles
Integration with Frameworks
Components
Avatar Badge BottomAppBar Button ButtonIcon Card Checkbox Chip CircularProgress Collapse Dialog Divider Dropdown Fab Icon Layout LinearProgress List Menu NavigationBar NavigationDrawer NavigationRail Radio RangeSlider Select SegmentedButton Slider Snackbar Switch Tabs TextField Tooltip TopAppBar
Functions
Libraries

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:

Card
<mdui-card style="width: 200px;height: 124px">Card</mdui-card>

Examples

Variant

The variant attribute determines the card's appearance.

Clickable

Add the clickable attribute to make the card interactive. This adds hover and click ripple effects.

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

AttributePropertyReflectTypeDefault
variantvariant'elevated' | 'filled' | 'outlined''elevated'

Defines the card variant. Possible values:

  • elevated: Shadowed, offering more separation from the background than filled, but less than outlined.
  • filled: Provides minimal separation from the background.
  • outlined: Bordered, providing the most separation from the background.
clickableclickablebooleanfalse

Makes the card clickable. If set, hover and click ripple effects are added.

disableddisabledbooleanfalse

Disables the card.

hrefhrefstring-

The URL for the link. When set, the component renders as an <a> element and supports link-related attributes.

downloaddownloadstring-

Downloads the linked URL.

Note: Only available when href is specified.

targettarget'_blank' | '_parent' | '_self' | '_top'-

Controls where the linked URL opens. Possible values:

  • _blank: Opens in a new tab or window.
  • _parent: Opens in the parent browsing context, or _self if there is no parent.
  • _self: Opens in the current browsing context (default).
  • _top: Opens in the topmost browsing context, or _self if there are no ancestors.

Note: Only available when href is specified.

relrel'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:

  • alternate: An alternate version of the current document.
  • author: The author of the current document or article.
  • bookmark: The permalink for the nearest ancestor section.
  • external: The referenced document is not part of the same site as the current document.
  • help: A link to context-sensitive help.
  • license: Content covered by the copyright license described by the referenced document.
  • me: Links to content owned by the current document's author.
  • next: The next document in the series.
  • nofollow: Not endorsed by the original author or publisher.
  • noreferrer: Prevents the Referer header from being sent. Same effect as noopener.
  • opener: Creates a new browsing context when the hyperlink would otherwise open in a top-level context that is not auxiliary (for example, when target="_blank" is specified).
  • prev: The previous document in the series.
  • search: Links to a resource that can be used to search through the current document and its related pages.
  • tag: Marks the current document with the given tag.

Note: Only available when href is specified.

autofocusautofocusbooleanfalse

Whether the element is focused when the page loads.

tabindextabIndexnumber-

The element's tab order when navigating with the Tab key.

Methods

NameParametersReturns
click
void

Simulates a mouse click on the element.

focus
  • options: FocusOptions (Optional)
void

Sets focus on the element. An optional object parameter may include a preventScroll property. If preventScroll is set to true, the page will not scroll to bring the focused element into view.

blur
void

Removes focus from the element.

Events

Name
focus

Emitted when the card gains focus.

blur

Emitted when the card loses focus.

Slots

Name
(default)

Card 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.

On this page