On this page Card Card

The m3e-card component is a flexible, expressive container for presenting a unified subject—text, media, and actions—on a visually distinct surface.

Installation
npm i @m3e/card
Usage

This section outlines usage examples and configuration guidance for the components in this package.

Anatomy

The m3e-card component provides a modular layout for structured content blocks. It exposes the following named slots:

Card Header
Card Content
Action
Card Footer
<m3e-card>
  <m3e-heading slot="header" variant="display" size="small">Card Header</m3e-heading>
  <div slot="content">Card Content</div>
  <div slot="actions">
    <m3e-button variant="filled">Action</m3e-button>
  </div>
  <div slot="footer">Card Footer</div>
</m3e-card>

You can change the horizontal alignment of the actions slot by adding an end attribute to the slotted element.

Card Header
Card Content
Action
<m3e-card>
  <m3e-heading slot="header" variant="display" size="small">Card Header</m3e-heading>
  <div slot="content">Card Content</div>
  <div slot="actions" end>
    <m3e-button variant="filled">Action</m3e-button>
  </div>
</m3e-card>

When using the default slot, the m3e-card will not add any padding.

Card content
<m3e-card>Card content</m3e-card>
Variants

There are three card appearance variants: filled (default), outlined, and elevated. Use the variant attribute to control a card's appearance.

Filled

Outlined

Elevated
<m3e-card variant="filled">
  <div slot="content">Filled</div>
</m3e-card>
<!-- Additional variants omitted for brevity -->
Inline

By default, cards are rendered as block-level elements. Use the inline attribute to make a card render inline with surrounding content.

Inline
<m3e-card inline>
  <div slot="content">Inline</div>
</m3e-card>
Orientation

By default, cards are oriented vertically. Use the orientation attribute to change the orientation to horizontal or vertically (default).

Horizontal
<m3e-card class="image-card" inline orientation="horizontal">
  <img slot="header" src="[YOUR IMAGE URL HERE]" />
  <div slot="content">Horizontal</div>
</m3e-card>
Actionable

Use the actionable attribute to configure a card as an actionable surface, allowing users to interact with the entire card as a single affordance. This pattern is ideal for navigation, selection, or triggering contextual behavior.

Filled Actionable

Outlined Actionable

Elevated Actionable
<m3e-card variant="filled" actionable>
  <div slot="content">Filled</div>
</m3e-card>
<!-- Additional variants omitted for brevity -->
Disabling

Use the disabled attribute to disable an actionable card. By default, disabled cards are not focusable with the keyboard. You can use the disabled-interactive attribute to support focusability of disabled controls to increase their discoverability.

Disabled

Disabled Interactive
<m3e-card variant="filled" actionable disabled>
  <div slot="content">Disabled</div>
</m3e-card>
<br />
<m3e-card variant="filled" actionable disabled-interactive>
  <div slot="content">Disabled Interactive</div>
</m3e-card>
Links

Actionable cards can also behave like links by specifying a URL using the href attribute. You can also specify target, rel and download similar to native anchor tags.

Google
<m3e-card actionable href="https://www.google.com" target="_blank">
  <div slot="content">Google</div>
</m3e-card>
Accessibility

By default, cards are not given an ARIA role, indicating that they are treated as neutral, non-semantic elements in the accessibility tree unless explicitly referenced or annotated.

Actionable cards are given ARIA role="button" indicating they are clickable elements that trigger actions.

When disabling using either the disabled or disabled-interactive attribute, aria-disabled="true" is used to convey to assistive technologies that the actionable card is disabled. If disabled using disabled-interactive, tabindex is retained to convey that the card continues to be interactive.

When href is specified, the ARIA role link is used instead of button to convey the actionable card provides an interactive reference to a resource. In addition, the component presents an internal anchor, hidden from assistive technologies, used to invoke native browser features such a context menu options and tooltips.

Native module support

This package uses JavaScript Modules. To use it directly in a browser without a bundler, use a module script similar to the following.

<script type="module" src="/node_modules/@m3e/card/dist/index.js"></script>

In addition, you must use an import map to include additional dependencies.

<script type="importmap">
  {
    "imports": {
      "lit": "https://cdn.jsdelivr.net/npm/lit@3.3.0/+esm",
      "@m3e/core": "/node_modules/@m3e/core/dist/index.js"
    }
  }
</script>

For production, use index.min.js for faster load times.

API

This package includes a Custom Elements Manifest (custom-elements.json), which documents the properties, attributes, slots, events and CSS custom properties of each component.

You can explore the API below, or integrate the manifest into your own tooling.