--- name: slidev-components description: Leverage Vue components in Slidev slides. Use this skill to add interactivity with built-in components or create custom ones. --- # Slidev Components This skill covers using Vue components in Slidev, including all built-in components and how to create custom interactive elements for your presentations. ## When to Use This Skill - Adding interactive elements to slides - Using built-in Slidev components - Creating custom Vue components - Building reusable presentation elements - Adding dynamic content ## Using Components Components can be used directly in Markdown: ```markdown # My Slide ``` ## Built-in Components ### Arrow Draws an arrow between points. ```markdown ``` **Props**: - `x1`, `y1`: Start coordinates - `x2`, `y2`: End coordinates - `color`: Arrow color - `width`: Line width ### VDragArrow Draggable arrow (useful for presentations). ```markdown ``` ### AutoFitText Automatically adjusts font size to fit container. ```markdown ``` **Props**: - `max`: Maximum font size - `min`: Minimum font size - `modelValue`: Text content ### LightOrDark Renders different content based on theme. ```markdown ``` ### Link Navigation link to other slides. ```markdown Go to slide 42 Go to intro ``` ### SlideCurrentNo / SlidesTotal Display slide numbers. ```markdown Slide of ``` ### Toc (Table of Contents) Generates a table of contents. ```markdown ``` **Props**: - `maxDepth`: Maximum heading depth - `mode`: Display mode (`all`, `onlyCurrentTree`, `onlySiblings`) ### Transform Applies CSS transforms. ```markdown
Scaled content
Rotated and scaled ``` **Props**: - `scale`: Scale factor - `rotate`: Rotation in degrees ### Tweet Embeds a tweet. ```markdown ``` ### Youtube Embeds a YouTube video. ```markdown ``` **Props**: - `id`: YouTube video ID - `width`, `height`: Dimensions ### SlidevVideo Embeds a video file. ```markdown ``` **Props**: - `autoplay`: Auto-play on slide enter - `controls`: Show video controls - `loop`: Loop video ### RenderWhen Conditional rendering based on context. ```markdown Only visible in slide view Only visible in presenter view ``` **Context options**: `slide`, `presenter`, `previewNext`, `print` ### VDrag Makes elements draggable. ```markdown
Drag me!
Positioned draggable ``` ## Animation Components ### VClick Reveals on click. ```markdown Revealed on first click Revealed on second click ``` ### VClicks Reveals children sequentially. ```markdown - First item - Second item - Third item ``` **Props**: - `depth`: Depth for nested lists - `every`: Items per click ### VAfter Reveals with the previous element. ```markdown First Appears with first ``` ### VSwitch Switches between content based on clicks. ```markdown ``` ## Creating Custom Components ### Basic Component Create `components/Counter.vue`: ```vue ``` Usage: ```markdown # Interactive Counter ``` ### Component with Slots ```vue ``` Usage: ```markdown This is a red card with important content. ``` ### Component with Slidev Context ```vue ``` ### Code Demo Component ```vue ``` ## Composables ### useNav Access navigation state: ```vue ``` ### useSlideContext Access slide context: ```vue ``` ## Global Components ### global-top.vue Appears above all slides: ```vue ``` ### global-bottom.vue Appears below all slides: ```vue ``` ## Component Patterns ### Progress Indicator ```markdown
/
``` ### Social Links ```vue ``` ### QR Code ```vue ``` ## Best Practices 1. **Keep Components Simple**: Focus on single responsibilities 2. **Use Props**: Make components configurable 3. **Style Scoped**: Avoid global style pollution 4. **Document Usage**: Add comments showing how to use 5. **Test Interactivity**: Verify components work in presenter mode ## Output Format When creating components, provide: ``` COMPONENT: [name] PURPOSE: [what it does] FILE: components/[Name].vue --- --- USAGE IN SLIDES: ```markdown <[Name] prop="value" /> ``` PROPS: - [propName]: [type] - [description] ```