Motion guide · 7 of 8
Your app's motion
A motion style is one object on ConfigProvider that sets how your whole app moves: by role, by component, and with presets for your own elements.
One object for the app
A style is one object on ConfigProvider: version: 1, a spring for everything inside, and keys by role or by component. For each component, its own motion wins, then its key in the style, then its role, then its built-in look. The roles:
overlay: Dialog, Drawer, BottomSheet, Popover, Menu, Tooltip, and the panels of Select, Combobox, DatePicker and TreeSelectlist: Toaster, Timeline, FileUpload, SpeedDial, DataTable rows, CommandPalette rows, Breadcrumb and AvatarGrouppress: what a press and a hover do to a Buttonreveal: content that comes and goes on its own, such as a Messagecontent: your elements inside a component, itstargets
By component
Every component with a motion prop has a key in the style, named after it: dialog, drawer, toaster, button, select and the rest. A key takes what that component's motion takes, so one style can restyle every dialog in the app, give drawers their own spring and shake every failed toast. In code, a key can carry hooks too; a style read from data can't.
<script setup lang="ts">
import { ConfigProvider } from 'vael-ui'
import type { MotionStyle } from 'vael-ui/motion'
const style: MotionStyle = {
version: 1,
spring: 'smooth',
dialog: { initial: { panel: { opacity: 0, y: 12, scale: '0.96' } } },
drawer: { spring: 'gentle' },
toaster: { states: { error: { toast: { x: [0, -6, 6, 0] } } } },
button: { states: { active: { root: { scale: '0.97' } } } },
}
</script>
<template>
<ConfigProvider :motion="style">
<RouterView />
</ConfigProvider>
</template>Presets
presets are your own entrances by name. Each works anywhere inside the provider as a modifier, v-animate.wiggle, or as a value, v-animate="'wiggle'". A preset holds what v-animate takes: initial, exit, timing, stagger, even states. Give one a built-in name, such as rise or pop, to change that entrance inside the provider. List your names in MotionPresets, and they autocomplete and a typo fails the type check.
const style: MotionStyle = {
version: 1,
presets: {
// Yours: v-animate.wiggle anywhere inside.
wiggle: { initial: { opacity: 0, rotate: -6 }, spring: 'bouncy' },
// A built-in name: changes .rise inside.
rise: { initial: { opacity: 0, y: 16 } },
},
}
// motion.d.ts: the names autocomplete, and a typo fails vue-tsc.
import 'vael-ui/motion'
declare module 'vael-ui/motion' {
interface MotionPresets {
wiggle: true
}
}Filters
filters names SVG filters that ConfigProvider puts on the page, so any element inside can use one with filter: url(#name). A goo, { blur: 8, contrast: [18, -7] }, melts shapes into each other where they meet.
const style: MotionStyle = {
version: 1,
filters: { goo: { blur: 8, contrast: [18, -7] } },
}
// Then, on any element inside: filter: url(#goo)A style from outside your code
parseMotionStyle checks a style from a settings page, a database or the network. It drops anything unsafe or unknown, and lists what it dropped in issues.