---
title: "Presets"
description: "Set the motion of the whole app, or of part of it, from one object."
canonical_url: "https://nanimejs.netlify.app/guides/presets"
---
# Presets

> Set the motion of the whole app, or of part of it, from one object.

A preset bundles transition styles, component defaults and composable
defaults into one object, so the motion of an app comes from one place.

## Pick a built-in preset

<render-code-block-preview :code="false" src="examples/getting-started/BuiltinPresetsDemo.vue">



</render-code-block-preview>

The `<AnimeTransition>` box (a `scale` transition) and the `useAnimate()` box
toggle every few seconds, and picking a preset toggles them immediately. Drag
the `useDraggable()` box to feel its release physics.

<table>
<thead>
  <tr>
    <th align="left">
      Preset
    </th>
    
    <th align="left">
      Motion
    </th>
    
    <th align="left">
      Enter / leave (slide, scale, list)
    </th>
    
    <th align="left">
      Easing
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td align="left">
      <code>
        nanime/presets/formal
      </code>
    </td>
    
    <td align="left">
      Calm and precise, no overshoot
    </td>
    
    <td align="left">
      150ms / 110ms
    </td>
    
    <td align="left">
      IBM Carbon productive curves
    </td>
  </tr>
  
  <tr>
    <td align="left">
      <code>
        nanime/presets/elegant
      </code>
    </td>
    
    <td align="left">
      Soft and unhurried, no overshoot
    </td>
    
    <td align="left">
      400ms / 280ms
    </td>
    
    <td align="left">
      IBM Carbon expressive curves
    </td>
  </tr>
  
  <tr>
    <td align="left">
      <code>
        nanime/presets/playful
      </code>
    </td>
    
    <td align="left">
      Bouncy, overshoots about 10% on the way in
    </td>
    
    <td align="left">
      spring / 180ms
    </td>
    
    <td align="left">
      <code>
        spring()
      </code>
      
      , with <code>
        in(3)
      </code>
      
       for exits
    </td>
  </tr>
</tbody>
</table>

`fade`, the default for `<AnimeTransition>`, is shorter than the other styles in
every preset and never overshoots.

Each preset redefines the built-in style names (`fade`, `slide-up`,
`slide-down`, `slide-left`, `slide-right`, `scale`, `swap`) with its own
timing, and adds a `list` style that `<AnimeTransitionGroup>` uses by
default. Each preset also sets the timing of `<AnimeLayoutGroup>`, the defaults of
`useAnimate()` and the release physics of `useDraggable()`.

<table>
<thead>
  <tr>
    <th align="left">
      Value
    </th>
    
    <th align="left">
      <code>
        formal
      </code>
    </th>
    
    <th align="left">
      <code>
        elegant
      </code>
    </th>
    
    <th align="left">
      <code>
        playful
      </code>
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td align="left">
      Slide distance
    </td>
    
    <td align="left">
      8px
    </td>
    
    <td align="left">
      12px
    </td>
    
    <td align="left">
      20px
    </td>
  </tr>
  
  <tr>
    <td align="left">
      <code>
        scale
      </code>
      
       starts at
    </td>
    
    <td align="left">
      0.96
    </td>
    
    <td align="left">
      0.97
    </td>
    
    <td align="left">
      0.85
    </td>
  </tr>
  
  <tr>
    <td align="left">
      <code>
        fade
      </code>
      
       enter / leave
    </td>
    
    <td align="left">
      110ms / 70ms
    </td>
    
    <td align="left">
      300ms / 240ms
    </td>
    
    <td align="left">
      200ms / 150ms
    </td>
  </tr>
  
  <tr>
    <td align="left">
      Moves and layout
    </td>
    
    <td align="left">
      240ms
    </td>
    
    <td align="left">
      500ms
    </td>
    
    <td align="left">
      spring
    </td>
  </tr>
  
  <tr>
    <td align="left">
      <code>
        useAnimate()
      </code>
    </td>
    
    <td align="left">
      240ms
    </td>
    
    <td align="left">
      400ms
    </td>
    
    <td align="left">
      400ms
    </td>
  </tr>
  
  <tr>
    <td align="left">
      <code>
        useDraggable()
      </code>
      
       release
    </td>
    
    <td align="left">
      stiffness 300, damping 34
    </td>
    
    <td align="left">
      stiffness 100, damping 20
    </td>
    
    <td align="left">
      stiffness 200, damping 28
    </td>
  </tr>
</tbody>
</table>

Each preset exports its easings by name: `standard`, `entrance` and `exit` from
`formal`, `glide` and `settle` from `elegant`, and `pop` and `bounce` from
`playful`. Pass one to any animation:

```ts
import { entrance } from 'nanime/presets/formal'

useAnimate(box, { x: 120, ease: entrance })
```

## Set a preset for the whole app

Pass the imported preset object to `nanime.preset` in `app.config.ts`, not a
preset name:

```ts [app/app.config.ts]
import formal from 'nanime/presets/formal'

export default defineAppConfig({
  nanime: {
    preset: formal,
  },
})
```

Component props, `provideAnimeDefaults()` and the rest of `app.config.ts`
win over the preset. The preset wins over the built-in defaults.

## Write a preset

Write your own when none of the built-in presets fits.

<table>
<thead>
  <tr>
    <th align="left">
      Key
    </th>
    
    <th align="left">
      Holds
    </th>
    
    <th align="left">
      Required
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td align="left">
      <code>
        shared
      </code>
    </td>
    
    <td align="left">
      Named transition styles the preset adds, in the same shape as <code>
        nanime.transitions
      </code>
      
      .
    </td>
    
    <td align="left">
      No
    </td>
  </tr>
  
  <tr>
    <td align="left">
      <code>
        components
      </code>
    </td>
    
    <td align="left">
      Default props for <code>
        transition
      </code>
      
      , <code>
        transitionGroup
      </code>
      
       and <code>
        layoutGroup
      </code>
      
      .
    </td>
    
    <td align="left">
      Yes
    </td>
  </tr>
  
  <tr>
    <td align="left">
      <code>
        composables
      </code>
    </td>
    
    <td align="left">
      Default parameters for <code>
        animate
      </code>
      
       and <code>
        draggable
      </code>
      
      .
    </td>
    
    <td align="left">
      Yes
    </td>
  </tr>
</tbody>
</table>

`composables` can be an empty object. `components` needs all three entries,
and each can be an empty object.

```ts [app/app.config.ts]
export default defineAppConfig({
  nanime: {
    preset: {
      shared: {
        pop: {
          enter: { opacity: [0, 1], scale: [0.4, 1], duration: 240, ease: 'outBack(3)' },
          leave: { opacity: 0, scale: 0.4, duration: 140, ease: 'in(3)' },
          move: { duration: 200, ease: 'out(3)' },
        },
      },
      components: {
        transition: { animation: 'pop' },
        transitionGroup: { animation: 'pop' },
        layoutGroup: { layoutOptions: { duration: 400, ease: 'out(3)' } },
      },
      composables: {
        animate: { duration: 400, ease: 'out(3)' },
        draggable: { releaseEase: 'out(3)' },
      },
    },
  },
})
```

The names in `shared` work in the animation props of
[the components](https://nanimejs.netlify.app/components/transition), the same as a style from
`app.config.ts`.

A style name is looked up in `nanime.transitions` first, then in the preset's
`shared` styles, then in the built-in styles. `enter-animation` and
`leave-animation` each look up their own name, so
`<AnimeTransition enter-animation="pop" leave-animation="fade">` takes `pop`
from the preset and `fade` from wherever `fade` is defined.

## Scope a preset to part of the app

Use `provideAnimeDefaults({ preset })` when one part of the app needs a
different preset. It replaces the app-wide preset, and any preset from a
parent component's call, for everything inside the calling component.

```vue [components/MarketingSection.vue]
<script setup lang="ts">
import playful from 'nanime/presets/playful'

provideAnimeDefaults({ preset: playful })
</script>
```


## Sitemap

See the full [sitemap](https://nanimejs.netlify.app/sitemap.md) for all pages.
