Skip to content
LIBRARYMotionUpdated

GradientBackground ​

Included in RC.12

Available in Mavis 0.1.0-rc.12 for Vue + Vite, Nuxt and NativeScript. Keep the Mavis packages at the same version.

Web preview
Open example ↗
vue
<MGradientBackground :colors="colors" :active="playing">
  <MText text="Make room for something good." />
</MGradientBackground>
PropTypeDefaultContract
colorsreadonly string[]#9C5270, #51847B, #D5AD6C2–8 six-digit HEX colors.
anglenumber130Linear gradient angle in degrees.
active / animatedbooleanfalse / trueOpt-in continuous rotation and palette transitions.
durationnumber120001000–120000ms per half turn.
height / radiusnumber / token280 / lg40–1600px/DIP and shared corner token.

Static by default, including SSR. Setting active starts Jolt angle motion. Palette changes animate without remounting slot content. Offer a visible play/pause control when enabling continuous motion. Reduced motion, hidden Web documents and unloaded/deactivated native views stop decoration. Web also pauses outside the viewport. Content remains interactive; choose foreground colors with adequate contrast across every palette.

vue
<script setup lang="ts">
import { computed, ref } from 'vue'
import { midnight } from '@getcortexlabs/mavis-core'
import { useCatalogLocale } from '../locale'
const props = defineProps<{ lang?: 'en' | 'pt' }>()
const { locale } = useCatalogLocale(() => props.lang)
const t = (en: string, br: string) => ((props.lang ?? locale.value) === 'pt' ? br : en)
const active = ref(false),
  alternate = ref(false),
  animated = ref(true)
const colors = computed(() =>
  alternate.value ? ['#263848', '#315D64', '#665B46'] : ['#32243C', '#70455E', '#895653'],
)
const draft = ref('')
</script>
<template>
  <MColumn gap="lg"
    ><MText text="FORMA STUDIO / ATMOSPHERE" variant="overline" tone="primary" /><MThemeProvider
      :theme="midnight"
      ><MGradientBackground
        id="studio-gradient"
        :colors="colors"
        :active="active"
        :animated="animated"
        :height="360"
        ><MColumn padding="xl" gap="lg" justify="center" height="100%"
          ><MText text="SOMETHING GOOD IS TAKING SHAPE." variant="overline" /><MText
            :text="t('Make room for the unexpected.', 'Abra espaço para o inesperado.')"
            variant="title" /><MText
            :text="
              t(
                'A little color changes the whole conversation.',
                'Um pouco de cor muda toda a conversa.',
              )
            " /></MColumn
      ></MGradientBackground> </MThemeProvider
    ><MRow gap="md" wrap
      ><MButton
        :text="t('Change atmosphere', 'Mudar atmosfera')"
        @click="alternate = !alternate" /><MSwitch
        v-model="active"
        :label="t('Continuous motion', 'Movimento contínuo')" /><MSwitch
        v-model="animated"
        :label="t('Animate palette', 'Animar paleta')" /></MRow
    ><MInput v-model="draft" :label="t('A thought to keep', 'Uma ideia para guardar')"
  /></MColumn>
</template>

On Web and NativeScript, an active gradient binds its angle to a repeating motion value. A full turn takes twice duration. Updating the palette during a turn preserves the angle already reached.

Desktop ​

The box paints a native linear gradient; with active, a timer turns its angle ten times a second until active turns off, motion is reduced or the box is removed. While the window is minimized or covered on the Mac, or hidden on Windows, the angle holds and turns on from there once it shows. See Desktop components.

Components for NativeScript and Web. Starting with Vue.