@slidev/docs 51.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +39 -0
  3. package/builtin/cli.md +96 -0
  4. package/builtin/components.md +359 -0
  5. package/builtin/layouts.md +217 -0
  6. package/custom/config-code-runners.md +78 -0
  7. package/custom/config-context-menu.md +40 -0
  8. package/custom/config-fonts.md +105 -0
  9. package/custom/config-highlighter.md +74 -0
  10. package/custom/config-katex.md +18 -0
  11. package/custom/config-mermaid.md +47 -0
  12. package/custom/config-monaco.md +99 -0
  13. package/custom/config-parser.md +232 -0
  14. package/custom/config-routes.md +28 -0
  15. package/custom/config-shortcuts.md +36 -0
  16. package/custom/config-transformers.md +43 -0
  17. package/custom/config-unocss.md +46 -0
  18. package/custom/config-vite.md +83 -0
  19. package/custom/config-vue.md +25 -0
  20. package/custom/directory-structure.md +134 -0
  21. package/custom/index.md +192 -0
  22. package/features/block-frontmatter.md +39 -0
  23. package/features/build-with-pdf.md +42 -0
  24. package/features/bundle-remote-assets.md +29 -0
  25. package/features/canvas-size.md +32 -0
  26. package/features/click-marker.md +31 -0
  27. package/features/code-block-line-numbers.md +32 -0
  28. package/features/code-block-max-height.md +32 -0
  29. package/features/direction-variant.md +31 -0
  30. package/features/draggable.md +82 -0
  31. package/features/drawing.md +74 -0
  32. package/features/eject-theme.md +27 -0
  33. package/features/frontmatter-merging.md +49 -0
  34. package/features/global-layers.md +99 -0
  35. package/features/icons.md +58 -0
  36. package/features/import-snippet.md +48 -0
  37. package/features/importing-slides.md +69 -0
  38. package/features/index.md +93 -0
  39. package/features/latex.md +80 -0
  40. package/features/line-highlighting.md +57 -0
  41. package/features/mdc.md +31 -0
  42. package/features/mermaid.md +37 -0
  43. package/features/monaco-editor.md +36 -0
  44. package/features/monaco-run.md +44 -0
  45. package/features/monaco-write.md +22 -0
  46. package/features/plantuml.md +26 -0
  47. package/features/prettier-plugin.md +55 -0
  48. package/features/recording.md +28 -0
  49. package/features/remote-access.md +69 -0
  50. package/features/rough-marker.md +46 -0
  51. package/features/shiki-magic-move.md +53 -0
  52. package/features/side-editor.md +17 -0
  53. package/features/slide-hook.md +33 -0
  54. package/features/slide-scope-style.md +44 -0
  55. package/features/slot-sugar.md +83 -0
  56. package/features/transform-component.md +29 -0
  57. package/features/twoslash.md +37 -0
  58. package/features/vscode-extension.md +80 -0
  59. package/features/zoom-slide.md +33 -0
  60. package/guide/animations.md +456 -0
  61. package/guide/component.md +36 -0
  62. package/guide/exporting.md +240 -0
  63. package/guide/faq.md +134 -0
  64. package/guide/global-context.md +169 -0
  65. package/guide/hosting.md +220 -0
  66. package/guide/index.md +161 -0
  67. package/guide/layout.md +32 -0
  68. package/guide/syntax.md +179 -0
  69. package/guide/theme-addon.md +62 -0
  70. package/guide/ui.md +86 -0
  71. package/guide/why.md +112 -0
  72. package/guide/write-addon.md +48 -0
  73. package/guide/write-layout.md +45 -0
  74. package/guide/write-theme.md +109 -0
  75. package/index.md +6 -0
  76. package/package.json +47 -0
  77. package/resources/addon-gallery.md +32 -0
  78. package/resources/covers.md +16 -0
  79. package/resources/learning.md +22 -0
  80. package/resources/showcases.md +10 -0
  81. package/resources/theme-gallery.md +32 -0
@@ -0,0 +1,33 @@
1
+ ---
2
+ relates:
3
+ - guide/faq#adjust-size
4
+ - features/canvas-size
5
+ - features/transform-component
6
+ tags: [layout]
7
+ description: |
8
+ Zoom the content of a slide to a specific scale.
9
+ ---
10
+
11
+ # Zoom Slides
12
+
13
+ You may find some slides in your presentation too spacious or too crowded. Slidev provides a `zoom` option for each slide that allows you to scale the content of a slide:
14
+
15
+ ```md
16
+ ---
17
+ zoom: 0.8
18
+ ---
19
+
20
+ # A Slide with lots of content
21
+
22
+ ---
23
+
24
+ # Other slides aren't affected
25
+ ```
26
+
27
+ To scale all the slides in your presentation, you can set the slide canvas size:
28
+
29
+ <LinkCard link="features/canvas-size" />
30
+
31
+ To adjust the size of some elements on your slides, you can use the `Transform` component:
32
+
33
+ <LinkCard link="features/transform-component" />
@@ -0,0 +1,456 @@
1
+ ---
2
+ outline: deep
3
+ ---
4
+
5
+ # Animation
6
+
7
+ Animation is an essential part of slide presentations. Slidev provides a variety of ways to animate your slides, from the simple to the complex. This guide will show you how to use them effectively.
8
+
9
+ ## Click Animation {#click-animation}
10
+
11
+ A "**click**" can be considered as the unit of animation steps in slides. A slide can have one or more clicks, and each click can trigger one or more animations - for example, revealing or hiding elements.
12
+
13
+ > [!NOTE]
14
+ > Since v0.48.0, we've rewritten the click animations system with much more consistent behaviors. It might change the behaviors of your existing slides in edge cases. While this page is showing the new click system, you can find more details about the refactor in [#1279](https://github.com/slidevjs/slidev/pull/1279).
15
+
16
+ ### `v-click` {#v-click}
17
+
18
+ To apply show/hide "click animations" for elements, you can use the `<v-click>` component or the `v-click` directive.
19
+
20
+ <!-- eslint-skip -->
21
+
22
+ ```md
23
+ <!-- Component usage:
24
+ this will be invisible until you press "next" -->
25
+ <v-click> Hello World! </v-click>
26
+
27
+ <!-- Directive usage:
28
+ this will be invisible until you press "next" the second time -->
29
+ <div v-click class="text-xl"> Hey! </div>
30
+ ```
31
+
32
+ ### `v-after` {#v-after}
33
+
34
+ `v-after` will turn the element visible when the previous `v-click` is triggered.
35
+
36
+ ```md
37
+ <div v-click> Hello </div>
38
+ <div v-after> World </div> <!-- or <v-after> World </v-after> -->
39
+ ```
40
+
41
+ When you press "next", both `Hello` and `World` will show up together.
42
+
43
+ ### Hide after clicking {#hide-after-clicking}
44
+
45
+ Add a `.hide` modifier to `v-click` or `v-after` directives to make elements invisible after clicking, instead of showing up.
46
+
47
+ ```md
48
+ <div v-click> Visible after 1 click </div>
49
+ <div v-click.hide> Hidden after 2 clicks </div>
50
+ <div v-after.hide> Hidden after 2 clicks </div>
51
+ ```
52
+
53
+ For the components, you can use the `hide` prop to achieve the same effect:
54
+
55
+ ```md
56
+ <v-click> Visible after 1 click </v-click>
57
+ <v-click hide> Hidden after 2 clicks </v-click>
58
+ <v-after hide> Also hidden after 2 clicks </v-after>
59
+ ```
60
+
61
+ ### `v-clicks` {#v-clicks}
62
+
63
+ `v-clicks` is only provided as a component. It's a shorthand to apply the `v-click` directive to all its child elements. It is especially useful when working with lists and tables.
64
+
65
+ ```md
66
+ <v-clicks>
67
+
68
+ - Item 1
69
+ - Item 2
70
+ - Item 3
71
+
72
+ </v-clicks>
73
+ ```
74
+
75
+ An item will become visible each time you click "next".
76
+ It accepts a `depth` prop for nested list:
77
+
78
+ ```md
79
+ <v-clicks depth="2">
80
+
81
+ - Item 1
82
+ - Item 1.1
83
+ - Item 1.2
84
+ - Item 2
85
+ - Item 2.1
86
+ - Item 2.2
87
+
88
+ </v-clicks>
89
+ ```
90
+
91
+ Also, you can use the `every` prop to specify the number of items to show after each click:
92
+
93
+ ```md
94
+ <v-clicks every="2">
95
+
96
+ - Item 1.1
97
+ - Item 1.2
98
+ - Item 2.1
99
+ - Item 2.2
100
+
101
+ </v-clicks>
102
+ ```
103
+
104
+ ### Positioning {#positioning}
105
+
106
+ By default, the clicking animations are triggered one by one. You can customize the animation "position" of elements by using the `at` prop or the `v-click` directive with value.
107
+
108
+ Like the CSS layout system, click-animated elements can be "relative" or "absolute":
109
+
110
+ #### Relative Position {#relative-position}
111
+
112
+ This actual position of relative elements is calculated based on the previous relative elements:
113
+
114
+ ````md
115
+ <div v-click> visible after 1 click </div>
116
+ <v-click at="+2"><div> visible after 3 clicks </div></v-click>
117
+ <div v-click.hide="'-1'"> hidden after 2 clicks </div>
118
+
119
+ ```js {none|1|2}{at:'+5'}
120
+ 1 // highlighted after 7 clicks
121
+ 2 // highlighted after 8 clicks
122
+ ```
123
+ ````
124
+
125
+ > [!NOTE]
126
+ > The default value of `v-click` is `'+1'` when you don't specify it.
127
+
128
+ In fact, `v-after` are just shortcuts for `v-click` with `at` prop:
129
+
130
+ ```md
131
+ <!-- The following 2 usages are equivalent -->
132
+ <img v-after />
133
+ <img v-click="'+0'" />
134
+
135
+ <!-- The following 3 usages are equivalent -->
136
+ <img v-click />
137
+ <img v-click="'+1'" />
138
+ <v-click-gap size="1" /><img v-after />
139
+ ```
140
+
141
+ ::: tip `at` prop value format
142
+ Only string values starting with `'+'` or `'-'` like `'+1'` are treated as relative positions:
143
+
144
+ | Value | Kind |
145
+ | -------------- | -------- |
146
+ | `'-1'`, `'+1'` | Relative |
147
+ | `+1` === `1` | Absolute |
148
+ | `'1'` | Absolute |
149
+
150
+ So don't forget the single quotes for the relative values.
151
+ :::
152
+
153
+ #### Absolute Position {#absolute-position}
154
+
155
+ The given value is the exact click count to trigger this animation:
156
+
157
+ ````md
158
+ <div v-click="3"> visible after 3 clicks </div>
159
+ <v-click at="2"><div> visible after 2 clicks </div></v-click>
160
+ <div v-click.hide="1"> hidden after 1 click </div>
161
+
162
+ ```js {none|1|2}{at:3}
163
+ 1 // highlighted after 3 clicks
164
+ 2 // highlighted after 4 clicks
165
+ ```
166
+ ````
167
+
168
+ #### Mixed Case {#mixed-case}
169
+
170
+ You can mix the absolute and relative positions:
171
+
172
+ ```md
173
+ <div v-click> visible after 1 click </div>
174
+ <div v-click="3"> visible after 3 clicks </div>
175
+ <div v-click> visible after 2 click </div>
176
+ <div v-click="'-1'"> visible after 1 click </div>
177
+ <div v-click="4"> visible after 4 clicks </div>
178
+ ```
179
+
180
+ The following example synchronizes the highlighting of the two code blocks:
181
+
182
+ ````md {1,6}
183
+ ```js {1|2}{at:1}
184
+ 1 + 1
185
+ 'a' + 'b'
186
+ ```
187
+
188
+ ```js {1|2}{at:1}
189
+ = 2
190
+ = 'ab'
191
+ ```
192
+ ````
193
+
194
+ ### Enter & Leave {#enter-leave}
195
+
196
+ You can also specify the enter and leave index for the `v-click` directive by passing an array. The end index is exclusive.
197
+
198
+ ```md
199
+ <div v-click.hide="[2, 4]">
200
+ This will be hidden at click 2 and 3.
201
+ </div>
202
+ <div v-click />
203
+ <div v-click="['+1', '+1']">
204
+ This will be shown at click 3, and hidden since click 4.
205
+ </div>
206
+ ```
207
+
208
+ You can also use `v-switch` to achieve the same effect:
209
+
210
+ ```md
211
+ <v-switch>
212
+ <template #1> show at click 1, hide at click 2. </template>
213
+ <template #2> show at click 2, hide at click 5. </template>
214
+ <template #5-7> show at click 5, hide at click 7. </template>
215
+ </v-switch>
216
+ ```
217
+
218
+ See [`VSwitch` Component](/builtin/components#vswitch) for more details.
219
+
220
+ ### Custom Total Clicks Count {#total}
221
+
222
+ By default, Slidev automatically calculates how many clicks are required before going to the next slide. You can override this via the `clicks` frontmatter option:
223
+
224
+ ```yaml
225
+ ---
226
+ # 10 clicks in this slide, before going to the next slide
227
+ clicks: 10
228
+ ---
229
+ ```
230
+
231
+ ### Element Transitions {#element-transitions}
232
+
233
+ When you apply the `v-click` directive to your elements, it will attach the class name `slidev-vclick-target` to it. When the elements are hidden, the class name `slidev-vclick-hidden` will also be attached. For example:
234
+
235
+ ```html
236
+ <div class="slidev-vclick-target slidev-vclick-hidden">Text</div>
237
+ ```
238
+
239
+ After a click, it may become:
240
+
241
+ ```html
242
+ <div class="slidev-vclick-target">Text</div>
243
+ ```
244
+
245
+ By default, a subtle opacity transition is applied to those classes:
246
+
247
+ ```css
248
+ /* below shows the default style */
249
+
250
+ .slidev-vclick-target {
251
+ transition: opacity 100ms ease;
252
+ }
253
+
254
+ .slidev-vclick-hidden {
255
+ opacity: 0;
256
+ pointer-events: none;
257
+ }
258
+ ```
259
+
260
+ You can override them to customize the transition effects in your custom stylesheets. For example, you can achieve the scaling up transitions by:
261
+
262
+ ```css
263
+ /* styles.css */
264
+
265
+ .slidev-vclick-target {
266
+ transition: all 500ms ease;
267
+ }
268
+
269
+ .slidev-vclick-hidden {
270
+ transform: scale(0);
271
+ }
272
+ ```
273
+
274
+ To specify animations for only certain slides or layouts:
275
+
276
+ ```scss
277
+ .slidev-page-7,
278
+ .slidev-layout.my-custom-layout {
279
+ .slidev-vclick-target {
280
+ transition: all 500ms ease;
281
+ }
282
+
283
+ .slidev-vclick-hidden {
284
+ transform: scale(0);
285
+ }
286
+ }
287
+ ```
288
+
289
+ Learn more about [customizing styles](/custom/directory-structure#style).
290
+
291
+ ## Motion {#motion}
292
+
293
+ Slidev has [@vueuse/motion](https://motion.vueuse.org/) built-in. You can use the `v-motion` directive to any elements to apply motion to them. For example
294
+
295
+ ```html
296
+ <div
297
+ v-motion
298
+ :initial="{ x: -80 }"
299
+ :enter="{ x: 0 }"
300
+ :leave="{ x: 80 }"
301
+ >
302
+ Slidev
303
+ </div>
304
+ ```
305
+
306
+ The text `Slidev` will move from `-80px` to its original position when entering the slide. When leaving, it will move to `80px`.
307
+
308
+ > Before v0.48.9, you need to add `preload: false` to the slide's frontmatter to enable motion.
309
+
310
+ ### Motion with Clicks {#motion-with-clicks}
311
+
312
+ > Available since v0.48.9
313
+
314
+ You can also trigger the motion by clicks:
315
+
316
+ ```html
317
+ <div
318
+ v-motion
319
+ :initial="{ x: -80 }"
320
+ :enter="{ x: 0, y: 0 }"
321
+ :click-1="{ x: 0, y: 30 }"
322
+ :click-2="{ y: 60 }"
323
+ :click-2-4="{ x: 40 }"
324
+ :leave="{ y: 0, x: 80 }"
325
+ >
326
+ Slidev
327
+ </div>
328
+ ```
329
+
330
+ Or combine `v-click` with `v-motion`:
331
+
332
+ ```html
333
+ <div v-click="[2, 4]" v-motion
334
+ :initial="{ x: -50 }"
335
+ :enter="{ x: 0 }"
336
+ :leave="{ x: 50 }"
337
+ >
338
+ Shown at click 2 and hidden at click 4.
339
+ </div>
340
+ ```
341
+
342
+ The meanings of variants:
343
+
344
+ - `initial`: When `currentPage < thisPage`, or `v-click` hides the current element because `$clicks` is too small.
345
+ - `enter`: When `currentPage === thisPage`, and `v-click` shows the element. _Priority: lowest_
346
+ - `click-x`: `x` is a number representing the **absolute** click num. The variant will take effect if `$clicks >= x`. _Priority: `x`_
347
+ - `click-x-y`: The variant will take effect if `x <= $clicks < y`. _Priority: `x`_
348
+ - `leave`: `currentPage > thisPage`, or `v-click` hides the current element because `$clicks` is too large.
349
+
350
+ The variants will be combined according to the priority defined above.
351
+
352
+ ::: warning
353
+ Due to a Vue internal [bug](https://github.com/vuejs/core/issues/10295), currently **only** `v-click` applied to the same element as `v-motion` can control the motion animation. As a workaround, you can use something like `v-if="3 < $clicks"` to achieve the same effect.
354
+ :::
355
+
356
+ Learn more: [Demo](https://sli.dev/demo/starter/10) | [@vueuse/motion](https://motion.vueuse.org/) | [v-motion](https://motion.vueuse.org/features/directive-usage) | [Presets](https://motion.vueuse.org/features/presets)
357
+
358
+ ## Slide Transitions {#slide-transitions}
359
+
360
+ <div id="pages-transitions" />
361
+
362
+ Slidev supports slide transitions out of the box. You can enable it by setting the `transition` frontmatter option:
363
+
364
+ ```md
365
+ ---
366
+ transition: slide-left
367
+ ---
368
+ ```
369
+
370
+ This will give you a nice sliding effects on slide switching. Setting it in the headmatter will apply this to all slides. You can also set different transitions per slide in frontmatters.
371
+
372
+ ### Builtin Transitions {#builtin-transitions}
373
+
374
+ - `fade` - Crossfade in/out
375
+ - `fade-out` - Fade out and then fade in
376
+ - `slide-left` - Slides to the left (slide to right when going backward)
377
+ - `slide-right` - Slides to the right (slide to left when going backward)
378
+ - `slide-up` - Slides to the top (slide to bottom when going backward)
379
+ - `slide-down` - Slides to the bottom (slide to top when going backward)
380
+ - `view-transition` - Via the view transitions API
381
+
382
+ ### View Transition API {#view-transitions}
383
+
384
+ The View Transitions API provides a mechanism for easily creating animated transitions between different DOM states. Learn more about it in [View Transitions API - MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API).
385
+
386
+ :::warning
387
+ Experimental: This is not supported by all browsers. Check the [Browser compatibility table](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API#browser_compatibility) carefully before using this.
388
+ :::
389
+
390
+ You can use the `view-transition-name` CSS property to name view transitions, which creates connections between different page elements and smooth transitions when switching slides.
391
+
392
+ You can enable [MDC (Markdown Component) Syntax](/guide/syntax#mdc-syntax) support to conveniently name view-transitions:
393
+
394
+ ```md
395
+ ---
396
+ transition: view-transition
397
+ mdc: true
398
+ ---
399
+
400
+ # View Transition {.inline-block.view-transition-title}
401
+
402
+ ---
403
+
404
+ # View Transition {.inline-block.view-transition-title}
405
+ ```
406
+
407
+ ### Custom Transitions {#custom-transitions}
408
+
409
+ Slidev's slide transitions are powered by [Vue Transition](https://vuejs.org/guide/built-ins/transition.html). You can provide your custom transitions by:
410
+
411
+ ```md
412
+ ---
413
+ transition: my-transition
414
+ ---
415
+ ```
416
+
417
+ and then in your custom stylesheets:
418
+
419
+ ```css
420
+ .my-transition-enter-active,
421
+ .my-transition-leave-active {
422
+ transition: opacity 0.5s ease;
423
+ }
424
+
425
+ .my-transition-enter-from,
426
+ .my-transition-leave-to {
427
+ opacity: 0;
428
+ }
429
+ ```
430
+
431
+ Learn more about how it works in [Vue Transition](https://vuejs.org/guide/built-ins/transition.html).
432
+
433
+ ### Forward & Backward Transitions {#forward-backward-transitions}
434
+
435
+ You can specify different transitions for forward and backward navigation using `|` as a separator in the transition name:
436
+
437
+ ```md
438
+ ---
439
+ transition: go-forward | go-backward
440
+ ---
441
+ ```
442
+
443
+ With this, when you go from slide 1 to slide 2, the `go-forward` transition will be applied. When you go from slide 2 to slide 1, the `go-backward` transition will be applied.
444
+
445
+ ### Advanced Usage {#advanced-usage}
446
+
447
+ The `transition` field accepts an option that will passed to the [`<TransitionGroup>`](https://vuejs.org/api/built-in-components.html#transition) component. For example:
448
+
449
+ ```md
450
+ ---
451
+ transition:
452
+ name: my-transition
453
+ enterFromClass: custom-enter-from
454
+ enterActiveClass: custom-enter-active
455
+ ---
456
+ ```
@@ -0,0 +1,36 @@
1
+ # Components in Slides
2
+
3
+ One of the most powerful features of Slidev is the ability to use Vue components directly in your slides. This allows you to create interactive and dynamic content with ease.
4
+
5
+ ## Using Components {#use}
6
+
7
+ With the help of [`unplugin-vue-components`](https://github.com/unplugin/unplugin-vue-components), Slidev allows you to use Vue components directly in your slides without importing them manually:
8
+
9
+ ```md
10
+ # My Slide
11
+
12
+ <MyComponent :count="4"/>
13
+ ```
14
+
15
+ The components come from:
16
+
17
+ - Built-in components. See [Built-in Components](../builtin/components) for reference.
18
+ - Provided by the theme and addons. See <LinkInline link="guide/theme-addon" />.
19
+ - Custom components in the `components` directory. See the next section.
20
+
21
+ ## Writing Components {#write}
22
+
23
+ To create a custom component, simply create a new Vue file in the `components` directory:
24
+
25
+ ```bash
26
+ your-slidev/
27
+ ├── ...
28
+ ├── slides.md
29
+ └── components/
30
+ ├── ...
31
+ └── MyComponent.vue
32
+ ```
33
+
34
+ Refer to the [Vue documentation](https://vuejs.org/guide/essentials/component-basics.html) for how to write Vue components.
35
+
36
+ You can also <LinkInline link="guide/write-addon" /> to reuse and share your components with others.