Skip to content
LIBRARYFeedbackUpdated

Skeleton ​

Alpha.8 adds effect="pulse|shimmer" (default pulse). Shimmer uses Jolt on Web, iOS and Android. animated=false removes the decoration. See visual motion; this requires Jolt RC.11 and is included in alpha.8.

MSkeleton represents the shape of content while the app loads its data. Combine blocks with Row and Column to compose cards, profiles or lists.

Next alpha

Available in 0.1.0-alpha.4.

Web preview
Open example ↗

Usage ​

vue
<template>
  <m-column v-if="loading" gap="md">
    <m-text>Loading profile…</m-text>
    <m-row gap="md">
      <m-skeleton :width="48" :height="48" radius="full" :shrink="0" />
      <m-column :width="0" :grow="1" gap="sm">
        <m-skeleton width="70%" />
        <m-skeleton width="45%" :height="12" />
      </m-column>
    </m-row>
  </m-column>
  <m-text v-else>{{ profile.name }}</m-text>
</template>

loading and profile belong to the app. The component does not fetch data, run a loading timer or choose between empty, error and success states.

Props ​

PropTypeDefaultBehavior
widthnumber | % | autoautoFills the available width in Column.
heightnumber | % | auto16Block height.
radiusradius token or numbersmCorner radius; full with equal dimensions produces a circle.
animatedbooleantrueEnables the pulse when system motion preferences allow it.
effectpulse | shimmer | wavepulsewave times each pulse by its position on screen, so neighbouring blocks read as one sweep.
loadingbooleantruefalse replaces the block with its default slot, which arrives in place.
indexnumber0Arrival order when several blocks hand over together.
grow / shrinknumber0 / contextLayout participation, as in Box.
idstring—Optional identifier.

Numbers use DIP on native and px on Web. Percentages require a parent with a defined size on the corresponding axis. auto does not measure future content: this block is empty. Set explicit dimensions to reserve space. In Row, use shrink=0 to preserve a circle's size. Automatic widths stretch within Column; explicit widths use flex-start to preserve narrower shapes. In Row, provide a width or use width=0 with grow=1 to share the available space.

State and composition ​

Skeleton has no slots, events or real content. Blocks are decorative: they cannot receive focus and are not announced individually. Provide one loading message for the region outside the blocks; announcing state changes and handling failures belong to the app. Do not nest a real form inside Skeleton to hide it.

The color uses theme.colors.border in Mavis and Midnight. Choose dimensions close to the expected result to reduce layout shifts. There is no automatic measurement, line-count group or sizing based on system text size.

In Library, Atualizar coleção simulates a 1.5-second wait. Placeholders replace the cards while filters, the active tab and saved readings are preserved. The example makes no network requests.

Motion and lifecycle ​

The pulse runs a 1.6-second opacity cycle through Jolt. A hidden Web tab or a backgrounded native app pauses it. Disabling animation or enabling reduced motion restores full opacity. Unloading the native view releases the playback and listeners.

Use a limited number of placeholders; scrolling out of the viewport does not unmount the component or stop its animation. Large lists need the app's virtualization strategy.

Hand-over ​

Wrap the real content in the skeleton and switch loading when it is ready. The content takes the block's place with a short rise, staggered by index. Content present on mount, including server-rendered content, appears without animation.

vue
<m-skeleton :loading="loading" width="70%" effect="wave" :index="1">
  <m-text variant="heading">{{ title }}</m-text>
</m-skeleton>

When loading ends, the content takes its place immediately. The placeholder finishes fading over it without reserving a second space.

Desktop ​

On the Mac and on Windows the shapes are hidden from assistive technology, pulse in a wave and hand over to their content. effect="shimmer" sweeps a highlight on the Mac; Windows pulses instead, because it does not clip a view to its corners yet. See Desktop components.

Full example ​

View source
vue
<script setup lang="ts">
import { useCatalogLocale } from '../locale'
import { computed, ref } from 'vue'
import { useMavisTheme } from '@getcortexlabs/mavis-core/vue'

const { t, locale } = useCatalogLocale(() => props.lang)

const props = withDefaults(defineProps<{ lang?: 'en' | 'pt' }>(), { lang: undefined })

const pt = computed(() => (props.lang ?? locale.value) === 'pt')
const { theme } = useMavisTheme()
const loading = ref(true)
const animated = ref(true)
</script>

<template>
  <m-column gap="lg">
    <m-column padding="lg" gap="md" radius="lg" :backgroundColor="theme.colors.accentSoft">
      <m-row justify="between" gap="sm">
        <m-text variant="overline" tone="accent">{{
          t(pt ? 'UMA PRÉVIA DO QUE VEM' : 'A GLIMPSE OF WHAT IS NEXT')
        }}</m-text>
        <m-icon name="book-open" tone="accent" />
      </m-row>
      <m-text variant="title">{{ t(pt ? 'O próximo capítulo.' : 'The next chapter.') }}</m-text>
      <m-text tone="muted">{{
        t(
          pt
            ? 'A espera também faz parte da experiência.'
            : 'Waiting is part of the experience, too.',
        )
      }}</m-text>
    </m-column>
    <m-text variant="caption" tone="muted">{{
      t(
        loading
          ? pt
            ? 'Preparando sua leitura…'
            : 'Preparing your reading…'
          : pt
            ? 'Sua leitura está pronta.'
            : 'Your reading is ready.',
      )
    }}</m-text>
    <m-card gap="lg">
      <m-row gap="md">
        <m-skeleton
          :loading="loading"
          :width="48"
          :height="48"
          radius="full"
          :shrink="0"
          effect="wave"
          :animated="animated"
        >
          <m-column
            :width="48"
            :height="48"
            radius="full"
            align="center"
            justify="center"
            :backgroundColor="theme.colors.primarySoft"
          >
            <m-icon name="sparkles" tone="primary" />
          </m-column>
        </m-skeleton>
        <m-column :width="0" :grow="1" :gap="loading ? 'sm' : 'xs'">
          <m-skeleton :loading="loading" width="70%" effect="wave" :animated="animated" :index="1">
            <m-text variant="heading">{{ t('Mavis Studio') }}</m-text>
          </m-skeleton>
          <m-skeleton
            :loading="loading"
            width="45%"
            :height="12"
            effect="wave"
            :animated="animated"
            :index="1"
          >
            <m-text variant="caption" tone="muted">{{
              t(pt ? '4 minutos de inspiração' : '4 minutes of inspiration')
            }}</m-text>
          </m-skeleton>
        </m-column>
      </m-row>
      <m-skeleton
        :loading="loading"
        :height="152"
        radius="md"
        effect="wave"
        :animated="animated"
        :index="2"
      >
        <m-column
          :height="152"
          padding="lg"
          radius="md"
          justify="between"
          :backgroundColor="theme.colors.primarySoft"
        >
          <m-text variant="overline" tone="primary"
            >01 / {{ t(pt ? 'PERSPECTIVAS' : 'PERSPECTIVES') }}</m-text
          >
          <m-text variant="title" tone="primary">{{
            t(pt ? 'Menos ruído.\nMais espaço.' : 'Less noise.\nMore space.')
          }}</m-text>
        </m-column>
      </m-skeleton>
      <m-column gap="sm">
        <m-skeleton
          :loading="loading"
          width="85%"
          :height="24"
          effect="wave"
          :animated="animated"
          :index="3"
        >
          <m-text variant="heading">{{
            t(pt ? 'Ideias precisam respirar.' : 'Ideas need room to breathe.')
          }}</m-text>
        </m-skeleton>
        <m-skeleton :loading="loading" effect="wave" :animated="animated" :index="4">
          <m-text tone="muted">{{
            t(
              pt
                ? 'Uma pausa, um novo olhar e espaço para descobrir o que importa.'
                : 'A pause, a fresh perspective and room to discover what matters.',
            )
          }}</m-text>
        </m-skeleton>
        <m-skeleton :loading="loading" width="65%" effect="wave" :animated="animated" />
      </m-column>
    </m-card>
    <m-button @click="loading = !loading">{{
      t(
        loading
          ? pt
            ? 'Mostrar conteúdo'
            : 'Show content'
          : pt
            ? 'Carregar novamente'
            : 'Load again',
      )
    }}</m-button>
    <m-switch v-model="animated" :label="t(pt ? 'Animar placeholders' : 'Animate placeholders')" />
  </m-column>
</template>

Components for NativeScript and Web. Starting with Vue.