Skip to content
LIBRARYNavigationUpdated

AppBar ​

Alpha.10

Available in Mavis alpha.11 for Vue Web and NativeScript. Keep core and renderer versions aligned.

Web preview
Open example ↗
vue
<MAppBar title="Library" back><template #actions>…</template></MAppBar>
PropertyTypeDefaultDescription
materialsolid / glassthemeSets the material for this component. See Bar and speed dial material.
titlestringrequiredScreen heading.
subtitlestring—Optional supporting text.
backbooleanfalseShows a back action.
backLabelstringBackAccessible action label.
navigateBack() => void / Promise—Overrides the installed navigation back handler.
condensedboolean—App-owned compact state. Leave it unset to keep the bar static.
motionScrollMotionScrollSource—Condenses with the scroll offset of a Screen; takes precedence over condensed.
condenseDistancenumber64Scroll distance, in px/DIP, over which the bar condenses.

A screen header with leading and actions slots. The back action awaits the app navigation handler and emits back on completion or error on failure. Install navigation once with createRouterNavigation for Vue Router, Nuxt or vue-router-ns, or pass navigateBack. This component does not create a native Page, router, sticky positioning or a second safe-area inset. Native MScreen owns its safe area. Place a header outside scrollable content (or use the existing retained-header recipe) when it must remain visible. The title wraps rather than clipping enlarged text.

Motion ​

A bar that condenses keeps its height and its tap targets. The title shrinks toward its leading edge, the subtitle fades upward and the title settles into the space it leaves, while a soft shadow and a hairline lift the bar off the content below. The title stays the page heading and the subtitle stays readable to assistive technology the whole time; only the presentation changes. The back and action buttons keep the Button press and the icon gesture.

Set condensed when the app decides, for example after its own scroll check, and the bar animates between the two states. Pass the same createMotionScrollSource() the scrolling Screen receives through motionScroll, and the bar follows the scroll offset frame by frame instead, over condenseDistance. The bar does not become sticky by itself: inside a scrolling Screen it moves with the content, and on the Web a position: sticky style keeps it in view while it condenses. With neither prop the bar renders exactly as before.

vue
<script setup lang="ts">
import { markRaw } from 'vue'
import { createMotionScrollSource } from '@getcortexlabs/mavis-core/experimental'
const scroll = markRaw(createMotionScrollSource())
</script>

<template>
  <MScreen scroll :motionScroll="scroll">
    <MAppBar title="Library" :motionScroll="scroll" style="position: sticky; top: 0" />
    …
  </MScreen>
</template>
vue
<script setup lang="ts">
import { computed, ref } from 'vue'
import { useCatalogLocale } from '../locale'
const props = defineProps<{ lang?: 'en' | 'pt' }>()
const { locale } = useCatalogLocale(() => props.lang)
const pt = computed(() => (props.lang ?? locale.value) === 'pt')
const t = (en: string, br: string) => (pt.value ? br : en)
const visits = ref(0)
const condensed = ref(false)
</script>

<template>
  <MColumn gap="md">
    <MAppBar
      :title="t('Collections', 'Coleções')"
      :subtitle="t('Keep what inspires you', 'Guarde o que inspira você')"
      back
      :condensed="condensed"
      :backLabel="t('Back', 'Voltar')"
      :navigateBack="
        () => {
          visits++
        }
      "
    >
      <template #actions
        ><MButton
          icon="plus"
          variant="ghost"
          :accessibilityLabel="t('New collection', 'Nova coleção')"
          @click="visits++"
      /></template>
    </MAppBar>
    <MSwitch
      id="app-bar-condensed"
      v-model="condensed"
      :label="t('Scrolled past the top', 'Conteúdo rolado')"
      :helperText="
        t(
          'The title shrinks toward its leading edge and the bar lifts.',
          'O título encolhe em direção ao início e a barra ganha elevação.',
        )
      "
    />
    <MText id="app-bar-visits" :text="`${t('Actions', 'Ações')}: ${visits}`" tone="muted" />
  </MColumn>
</template>

Desktop ​

The bar uses its title as the window title and restores the previous title when it unmounts. Pass the same motionScroll to the bar and the scrolling screen. Scrolling past condenseDistance shows the compact title and shadow. Scrolling back expands the title. See Desktop components.

Components for NativeScript and Web. Starting with Vue.