Confetti
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.
<MConfetti :trigger="celebration" :count="70">
<MButton text="Publish" @click="celebration++" />
</MConfetti>| Prop | Type | Default | Contract |
|---|---|---|---|
trigger | string or number | 0 | Changing the token requests one burst; initial render/hydration never emits. |
count / colors | number / string[] | 70 / palette | 1–180 pieces and 2–8 six-digit HEX colors. |
disabled | boolean | false | Disposes an active burst and rejects new ones. |
The exposed burst() requests a celebration; stop() disposes it. A repeated request replaces the previous burst. Jolt owns the finite lifetime and cleanup; the component does not claim a completion callback. The burst event means a request started; skipped reports disabled, reduced-motion or unavailable. Keep success messages independent from decoration so every user receives confirmation. No browser-only imports are required in shared screens.
burst → void; skipped → disabled | reduced-motion | unavailable.
<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 t = (en: string, br: string) => ((props.lang ?? locale.value) === 'pt' ? br : en)
const trigger = ref(0),
count = ref(70),
disabled = ref(false),
status = ref('')
function celebrate() {
trigger.value++
status.value = t('Published. You made it.', 'Publicado. Você conseguiu.')
}
</script>
<template>
<MColumn gap="lg"
><MText text="FORMA STUDIO / THE FINISHING TOUCH" variant="overline" tone="primary" /><MConfetti
id="studio-confetti"
:trigger="trigger"
:count="count"
:disabled="disabled"
><MCard padding="xl" gap="lg"
><MBadge :text="t('READY FOR THE WORLD', 'PRONTO PARA O MUNDO')" /><MText
:text="
t('The work is done. Take a moment.', 'O trabalho está pronto. Aproveite o momento.')
"
variant="title" /><MText
:text="
t(
'A small celebration for a real accomplishment.',
'Uma pequena celebração para uma conquista de verdade.',
)
"
tone="muted" /><MButton
:text="t('Publish the project', 'Publicar o projeto')"
@click="celebrate" /><MText
id="confetti-status"
:text="status"
variant="heading" /></MCard></MConfetti
><MText
:text="`${t('Confetti pieces', 'Quantidade de confetes')}: ${count}`"
variant="caption" /><MSlider
v-model="count"
:min="10"
:max="180"
:step="10"
:label="t('Confetti pieces', 'Quantidade de confetes')" /><MSwitch
v-model="disabled"
:label="t('Disable celebration', 'Desativar celebração')"
/></MColumn>
</template>Desktop
A burst draws its pieces in the layer above the window, from the top of the component, and releases them when they land; the pieces never take the pointer. With reduced motion or disabled the component emits skipped instead. See Desktop components.