Skip to content
LIBRARYBase

Card ​

m-card · A themed surface for related content.

Web preview
Open example ↗

Usage ​

vue
<m-card gap="md">
  <m-text variant="heading">Your space</m-text>
  <m-text tone="muted">Content that belongs together.</m-text>
</m-card>

API ​

PropTypeDefaultPurpose
gaptoken / numbernoneSpace between children.
paddingtoken / numberlgInternal spacing.
radiustoken / numberlgSurface corners.
interactivebooleanfalseMakes the entire surface an action.
disabledbooleanfalseDisables an interactive card.
accessibilityLabelstring—Accessible name of the action, or of a card that only shows something.

Children are arranged vertically. Surface and border colors come from the theme. Enable interactive for a single action across the whole area, with press feedback. On the Web, the card receives focus and responds to Enter and Space. @click has no payload and is not emitted while disabled is active. Provide accessibilityLabel to describe the action. An interactive card may contain buttons or inputs: each child owns its action, and disabled blocks only the card action. Keep linked cards (href) free of nested controls.

A card with an accessibilityLabel and no action, such as a tile showing a number and its caption, is read as one element with that label: its content is hidden from assistive technology, so leave the label off a card that holds controls. On NativeScript an explicit accessible attribute decides instead, and on the Web an explicit role. It also accepts the composition props below.

Composition props ​

padding, paddingX, paddingY, radius, grow, shrink, width, height and backgroundColor are also accepted. paddingX and paddingY override their respective sides. Row, Column and Box start without padding; Card starts at lg. grow defaults to 0; shrink follows the parent context.

Full example ​

This file also runs in the NativeScript catalog and the Web preview.

View source
vue
<script setup lang="ts">
import { useCatalogLocale } from '../locale'
import { ref } from 'vue'

const { t } = useCatalogLocale()

withDefaults(defineProps<{ lang?: 'en' | 'pt' }>(), { lang: 'pt' })
const saved = ref(false)
const opened = ref(0)
</script>

<template>
  <m-column gap="lg">
    <m-card gap="md">
      <m-text variant="overline" tone="muted">{{ t('COLLECTION / 01') }}</m-text>
      <m-text variant="heading">{{
        t(lang === 'pt' ? 'Um espaço seu.' : 'A space of your own.')
      }}</m-text>
      <m-text tone="muted">{{
        t(
          lang === 'pt'
            ? 'Texto, ações e conteúdo com o mesmo ritmo.'
            : 'Text, actions and content with a shared rhythm.',
        )
      }}</m-text>
      <m-button variant="secondary" @click="saved = !saved">
        {{
          t(
            saved
              ? lang === 'pt'
                ? 'Salvo na coleção'
                : 'Saved to collection'
              : lang === 'pt'
                ? 'Salvar na coleção'
                : 'Save to collection',
          )
        }}
      </m-button>
    </m-card>
    <m-card
      interactive
      gap="sm"
      id="card-demo-open"
      :accessibilityLabel="
        t(lang === 'pt' ? 'Abrir a coleção Outono' : 'Open the Autumn collection')
      "
      @click="opened++"
    >
      <m-row gap="md" align="center">
        <m-box :width="56" :height="56" radius="md" backgroundColor="#F2A9C8" />
        <m-column gap="xs" :grow="1" :width="0">
          <m-text variant="overline" tone="muted">{{
            t(lang === 'pt' ? 'COLEÇÃO / 02' : 'COLLECTION / 02')
          }}</m-text>
          <m-text variant="heading">{{ t(lang === 'pt' ? 'Outono' : 'Autumn') }}</m-text>
          <m-text variant="caption" tone="muted">{{
            t(
              opened
                ? lang === 'pt'
                  ? `Aberta ${opened}×`
                  : `Opened ${opened}×`
                : lang === 'pt'
                  ? 'Passe o ponteiro, foque ou toque.'
                  : 'Hover, focus or tap it.',
            )
          }}</m-text>
        </m-column>
        <m-icon name="arrow-up-right" tone="muted" />
      </m-row>
    </m-card>
  </m-column>
</template>

In context ​

See the components in a complete vehicle controls screen.

Accessible names, focus and screen-reader checks.

Customization ​

The theme provides component defaults and Web CSS custom properties. See Typography and customization for tokens, supported overrides and precedence.

elevation="none | sm | md | lg" selects the shadow; without the prop, it uses components.card.elevation. The Mavis default is none.

Alpha.4 adds experimental motionSurface for continuous values, spring followers and drag/snap composed with press. Read the motion contract.

On an interactive Web card, bind :aria-pressed="selected" to expose a toggle choice on the focusable button. Pair it with accessibilityLabel to give each choice a stable name.

Motion ​

A plain card stays still. An interactive card (or one with href) answers the pointer on Web: a soft glare in the primary color follows the cursor, and the surface rises one elevation step on hover and on keyboard focus. Pressing sinks it with the shared press spring on both renderers; on touch screens that is the whole effect. The glare and the lifted shadow are decorative layers added on the first hover, so content, roles and an application motionSurface keep their own transforms. Forced colors hide them and reduced motion settles the press immediately.

Set href to render a single Web anchor. navigate, target and rel follow the Link contract, including RouterLink/NuxtLink custom slots, modified clicks and native host routing. error reports rejected navigation. A linked card must not contain other controls.

A link card can provide a labelled sharedTag for navigation back to a virtualized photo. On Web the shared transition owns the tagged card’s transform during activation.

Components for NativeScript and Web. Starting with Vue.