# Slides ## Creating Slides To create a slide use the `` component inside the `` component: ```svelte

🪄 Animotion

``` The `` component uses CSS grid by default for the layout, so it's not necessary to specify the display mode. ## Slide Events You can use the `in` and `out` props to pass a callback which runs when the slide enters and exits the viewport: ```svelte alert('slide 1 enter')} out={() => alert('slide 1 exit')}>

Slide 1

alert('slide 2 enter')} out={() => alert('slide 2 exit')}>

Slide 2

``` ## Components Svelte is a declarative JavaScript framework, so components are a great way to organize, and make your code reusable. This could be a `` component inside the `lib` folder: ```svelte ``` You can import, and use the `` component inside the slide: ```svelte ``` ## Options You can pass an `options` prop to the `` component: ```svelte ``` You can change the slide animation, show or hide the controls, and show the current slide in the URL hash among other options. # Transitions > ⚠️ Animotion uses the [View Transitions API (single document)](https://caniuse.com/view-transitions) which is Baseline newly available since Oct 2025. The core presentation features still work in older browsers, but they might not show all transitions. ## Animating elements You can use the `` component to animate changes in your slide like magic: ```svelte

🪄 Animotion

text.classList.replace('text-8xl', 'text-6xl')} class="mt-16" >
``` ## How Transitions Work Animotion uses the [View Transitions API](https://developer.mozilla.org/en-US/docs/Web/API/View_Transition_API) to animate the layout of your slides. The `` component is a `
` wrapper with a unique `view-transition-name` name, so the browser knows what element should transition after the DOM changed: ```svelte
``` You can use the `` component purely as a layout animation trigger without having to pass any children: ```svelte /* code that causes DOM change */ } /> ``` Animotion is going to run the function passed to the `do` prop before animating the layout, and invoke the `startViewTransition()` method on the document. This is very useful for revealing or hiding elements like a code block and its output: ```svelte {#if state === 'code'} {/if} {#if state === 'output'} {/if} state = 'code'}> state = 'output'}> ``` In this example we use the `visible` prop to show the element by default, so we can smoothly animate the layout when `state` changes using `` as a layout animation trigger. If you don't want the `` element to affect the layout when using it between elements, you can use the `hidden` prop to hide it: ```svelte /* code that causes DOM change */ } hidden /> ``` ## Custom Entry And Exit Transitions You can find the default view transition styles in `app.css`: ```css /* view transitions */ html { view-transition-name: none; } /* all view transitions */ ::view-transition-group(*) { animation-duration: var(--view-transition-duration); animation-timing-function: var(--ease); } /* entry transition */ ::view-transition-new(*):only-child { animation: scale-in var(--view-transition-duration) var(--ease); } /* exit transition */ ::view-transition-old(*):only-child { animation: scale-out var(--view-transition-duration) var(--ease); } @keyframes scale-in { from { scale: 0; opacity: 0; } } @keyframes scale-out { to { scale: 0; opacity: 0; } } ``` You can create your own entry and exit animations inside `app.css`: ```css @keyframes rotate { from { opacity: 0; } 20% { rotate: 0deg; } 40% { opacity: 1; } to { rotate: 360deg; } } ``` ...then pass the animation to the `entry` and `exit` props of the `` component, including the `duration` and `delay` in seconds: ```svelte {#each items as item, i} {/each} ``` ## Transition order You can use the `order` prop to specify the order in which the elements should transition: ```svelte
1 2 3 4
``` ## Layout animations You can do impossible layout animations, like animating between a `flex` and `grid` layout among other things — the only thing you have to do is change the DOM, and leave the rest to Animotion: ```svelte
{#each items as item (item)} {item} {/each}
layout = 'grid grid-cols-2 grid-rows-2 gap-4', () => items = [4, 3, 2, 1], () => items = [2, 1, 4, 3], () => items = [4, 3, 2, 1], () => items = [1, 2, 3, 4], () => layout = 'flex gap-4' ]} />
``` # Actions ## Control the presentation You can use the `` component to step through the presentation, and run code that updates the presentation: ```svelte let count = $state(0) <\/script> `} /> code.selectLines`2`} /> code.selectToken`5 count ++`} /> code.selectToken`{count}`} /> code.selectLines`*`} /> ``` ## Multiple actions Instead of having to define each action separately, you can use the `actions` prop to define multiple actions. ```svelte { example.selectLines`*` }} actions={[ () => example.selectLines`2`, () => example.selectLines`5 count ++`, () => example.selectLines`{count}`, () => example.selectLines`*` ]} /> ``` ## Undo You can pass an optional `undo` prop with a callback to the `` component that runs when you go back a step if you need to revert to some previous state: ```svelte /* ... */} undo={() => /* ... */} /> ``` # Code ## Animating code The `` component uses [Shiki](https://shiki.style/) for beautiful syntax highlighting: ```svelte let count = 0 $: double = count * 2 <\/script> `} options={{ duration: 1000, stagger: 0.3, lineNumbers: true, containerStyle: false }} /> code.update` { expression = 'true' code.update`let bool = ${expression}` }} > ``` ## Code Indentation Indenting code creates extra whitespace: ```svelte -> code = ref} lang="svelte" theme="poimandres" codes={[ ` ` in your code block is going to cause problems because Svelte thinks you're trying to close the ` {cx.current.toFixed(0)} ``` To create a value that you want to animate over time, use the `tween` method. To animate the value, use the `to` method. You can use the `await` keyword to wait for the animation to finish. You can animate any value, including CSS properties using the `style` attribute, or Svelte's `style:` directive: ```svelte

Motion

Motion

``` ## Tween multiple values You can `tween` a single value, objects, arrays, and override the default animation options using the `duration`, `delay`, and `easing` options: ```svelte ``` You can use `obj.current.property` to access the object property, but Motion creates an accessor for every property, so you can omit `.current` and say `obj.property`. ## Combine animations If you want to play multiple animations at the same time without having to think about where to put the `await` keyword you can combine them using the `all` helper method: ```svelte {text.count.toFixed(0)} ``` ## Sound Effects Besides playing animations you can play sounds using the `sfx` method. After you place your sounds in the `static` folder at the root of your project, they become available from the root `/` of your site: ```svelte ``` ## Reset Instead of reloading the page to reset the state of your animation, you can use the `reset` method on the `tween` to reset the animation back to its initial state. ```svelte value.reset()}> ``` # Styling ## Using Tailwind CSS You have complete control over unstyled elements using Tailwind: ```svelte
red
green
blue
``` Thanks to the Tailwind compiler you can pass arbitrary values surrounded by brackets like `h-[240px]` if the provided utility classes aren't enough. If you enjoy Tailwind get the [Tailwind CSS IntelliSense](https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss) extension for VS Code to make your life easier. To keep things organized Animotion also sorts the Tailwind classes for you. ## Using regular CSS You can write regular CSS inside a ` ``` ## Programmatic Slides Animotion exposes the `Reveal` instance using the `getPresentation` method, enabling you to use the API to control slides programmatically: ```svelte ``` You can look at the available [API methods](https://revealjs.com/api/). # File-based slides You can have slides in one file or split them into multiple files by default, but Animotion also provides a file-based slides option during the setup if you want the slides to be managed for you. ## Using File-based Slides This is how you create slides using the default setup: ```svelte

🪄 Animotion

``` This is how you create slides using file-based slides: ```svelte

🪄 Animotion

``` ```svelte ``` You can number the slides however you want since slides are sorted lowest to highest based on the number — another benefit of file-based slides is that you can have assets related to the slide in the same folder. ## Passing Props If you need to pass props to the `` use `

🪄 Animotion

``` For regular imports use the `

🪄 Animotion

``` ## File-Based Slides Setup You can also set up file-based slides yourself by copying this code inside `src/routes/+page.svelte`: ```svelte ``` After that you can create slides inside the `src/slides` folder. # Recording Videos ## Using The Recorder You can record your presentation using the `` component: ```svelte ``` - After you import the `` component you're going to be asked to give permission to share your screen, and microphone - Select the window, or screen you want to record, and press `F11` to fullscreen your browser and start recording ## Default Settings The default settings give you a nice balance of quality, and file size but you can use the [YouTube recommended upload encoding settings](https://support.google.com/youtube/answer/1722171?hl=en#zippy=%2Cbitrate) to change it. > ⚠️ Before you start recording do a test recording to make sure everything is working properly, and adjust the settings accordingly. These are the default video settings: ```svelte ``` - **MP4** container (**VP9** video codec, **Opus** audio codec) - **60** FPS - **2,5 mbps** (2500 kbps) video bitrate - **320 kbps** audio bitrate - Captures system audio - **Timer** enabled - **Microphone** enabled ## You Can Change The Video Type You can change the video container, and codecs like in this example which uses the [AVC (H.264)](https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Video_codecs#avc_h.264) video codec, and [AAC](https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Audio_codecs#aac_advanced_audio_coding) for the audio codec: ```svelte ``` For available options you can read the [Web video codec guide](https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Video_codecs) for the video codec options, and [Web audio codec guide](https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Audio_codecs) for the audio codec options. # Speaker notes You can write down notes inside the `` component for the current slide which is visible when you press the `S` key on the keyboard. ![Speaker notes](/notes.png) ```svelte

Horizontal 1

Don't make eye contact
Horizontal 2
``` # Math You can use [KaTeX](https://katex.org/) to write math formulas. ```svelte

The probability of getting {`\\(k\\)`} heads when flipping {`\\(n\\)`} coins

{` \\[P(E) = {n \\choose k} p^k (1-p)^{ n-k} \\] `}
```