The effect of gradually changing an element from one style to another.

Code Demo

Basic usage

Wrap the element in the transition component, and there will be a corresponding transition animation when the element is displayed/hidden.

<z-transition v-model:show="show">Content</z-transition>

Animation type

The transition component has a variety of built-in animations, and the animation type can be specified through the name field.

   <z-cell is-link title="Fade" @click="animate('fade')" />
   <z-cell is-link title="Slide Up" @click="animate('slide-up')" />
   <z-cell is-link title="Slide Down" @click="animate('slide-down')" />
   <z-cell is-link title="Slide Left" @click="animate('slide-left')" />
   <z-cell is-link title="Slide Right" @click="animate('slide-right')" />
<z-transition v-model:show="show" :name="transitionName">
   <view class="demo-animate-content">
     <view class="demo-animate-block" />
<script setup lang="ts">
import { ref } from 'vue'

const show = ref(false)
const transitionName = ref('')

const animate = (newName: string) => {
   show.value = true
   transitionName.value = newName

   setTimeout(() => {
     show.value = false
   }, 500)
<style lang="scss" scoped>
.demo-transition {
   .demo-animate-content {
     display: flex;
     align-items: center;
     justify-content: center;
     width: 100%;
     height: 500rpx;

     .demo-animate-block {
       width: 200rpx;
       height: 200rpx;
       background-color: var(--z-blue);
       border-radius: 16rpx;



ParametersDescriptionTypeDefault value
nameanimation typestringfade
showWhether to display the componentbooleantrue
durationanimation duration in millisecondsnumber | object300
custom-stylecustom styleobject-


Event nameDescriptionParameters
before-enterTrigger before entering-
enterTriggered when entering-
after-enterTriggered after entering-
before-leaveTriggered before leaving-
leaveTriggered while leaving-
after-leaveTriggered after leaving-

Animation type

fadefade in
fade-upSlide up and fade in
fade-downSlide down and fade in
fade-leftSlide left to fade in
fade-rightSlide right to fade in
slide-upSlide up to enter
slide-downSlide down to enter
slide-leftSlide left to enter
slide-rightSlide right to enter