返回 slidev
layout-global-layers.md
根目录 / skills / slidev / references / layout-global-layers.md
1 ---
2 name: global-layers
3 description: Create components that persist across slides like footers and backgrounds
4 ---
5
6 # Global Layers
7
8 Create components that persist across slides.
9
10 ## Layer Files
11
12 Create in project root:
13 - `global-top.vue` - Above all slides (single instance)
14 - `global-bottom.vue` - Below all slides (single instance)
15 - `slide-top.vue` - Above each slide (per-slide instance)
16 - `slide-bottom.vue` - Below each slide (per-slide instance)
17 - `custom-nav-controls.vue` - Custom navigation controls
18
19 ## Z-Order (top to bottom)
20
21 1. NavControls / custom-nav-controls.vue
22 2. global-top.vue
23 3. slide-top.vue
24 4. Slide Content
25 5. slide-bottom.vue
26 6. global-bottom.vue
27
28 ## Example: Footer
29
30 ```html
31 <!-- global-bottom.vue -->
32 <template>
33 <footer class="absolute bottom-0 left-0 right-0 p-2">Your Name</footer>
34 </template>
35 ```
36
37 ## Conditional Rendering
38
39 ```html
40 <!-- Hide on cover layout -->
41 <template>
42 <footer v-if="$nav.currentLayout !== 'cover'" class="absolute bottom-0 p-2">
43 {{ $nav.currentPage }} / {{ $nav.total }}
44 </footer>
45 </template>
46 ```
47
48 ## Export Note
49
50 Use `--per-slide` export option when global layers depend on navigation state.
51
51 lines MARKDOWN