ParticleField
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.
<MParticleField :active="playing" :density="12" :speed="28">
<MText text="Room for wonder." />
</MParticleField>| Prop | Type | Default | Contract |
|---|---|---|---|
active | boolean | false | Explicit request to emit decorative particles. |
colors / shape | string[] / circle, rectangle, ring | palette / circle | 2–8 six-digit HEX colors and particle shape. |
density / lifetime | number | 12 / 3000 | 1–60 particles/second, 100–5000ms lifetime: at most 300 live particles. |
speed / size / duration | number | 28 / 3 / continuous | Speed 0–300px or DIP/s, size 1–24, optional finite emission 100–60000ms. |
height / radius / backgroundColor | number / token / string | 280 / lg / #202A32 | Surface size, corners and static backdrop. |
Uses the Jolt emitter, with no component animation loop or particle solver. Pausing disposes existing particles; resuming starts a new field. Duration limits emission; existing particles may live until their lifetime ends. Reduced motion suppresses emission. Web pauses outside the viewport/background; native stops on unload, deactivation or application suspension. The slot remains mounted and usable. Provide a visible pause control for continuous emission.
<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),
density = ref(12),
speed = ref(28)
</script>
<template>
<MColumn gap="lg"
><MText text="FORMA STUDIO / AFTER HOURS" variant="overline" tone="primary" /><MThemeProvider
:theme="midnight"
><MParticleField
id="studio-particles"
:active="active"
:density="density"
:speed="speed"
:colors="['#F2CF92', '#91CCC4', '#C4AEDE']"
:height="340"
><MColumn padding="xl" gap="md" justify="center" height="100%"
><MText text="THE QUIET BETWEEN IDEAS" variant="overline" /><MText
:text="t('Leave a little room for wonder.', 'Deixe um pouco de espaço para o encanto.')"
variant="title" /><MText
:text="
t(
'A decorative layer. Your content stays yours.',
'Uma camada decorativa. Seu conteúdo continua seu.',
)
" /></MColumn
></MParticleField> </MThemeProvider
><MSwitch v-model="active" :label="t('Play particles', 'Ativar partículas')" /><MText
:text="`${t('Density', 'Densidade')}: ${density}`"
variant="caption" /><MSlider
v-model="density"
:min="1"
:max="40"
:label="t('Density', 'Densidade')" /><MText
:text="`${t('Speed', 'Velocidade')}: ${speed}`"
variant="caption" /><MSlider
v-model="speed"
:min="0"
:max="100"
:label="t('Speed', 'Velocidade')"
/></MColumn>
</template>Desktop
While active, particles rise from the bottom of the box as native views moved by the Jolt desktop drivers, added and released four times a second; turning active off, reduced motion, minimizing or covering the window on the Mac or hiding it on Windows, or removing the field releases them all; a field without duration starts again when the window shows, while a burst cut short this way is not played again. Windows does not clip yet, so there a fast particle can be drawn above the box. See Desktop components.