docs/features/draggable.md
Draggable elements give you the ability to move, resize, and rotate elements by dragging them with the mouse. This is useful for creating floating elements in your slides.
---
dragPos:
square: Left,Top,Width,Height,Rotate
---
::: warning Slidev use regex to update the position value in the slide content. If you meet problems, please use the frontmatter to define the values instead. :::
---
dragPos:
foo: Left,Top,Width,Height,Rotate
---
<v-drag pos="foo" text-3xl>
<div class="i-carbon:arrow-up" />
Use the `v-drag` component to have a draggable container!
</v-drag>
<v-drag pos="Left,Top,Width,Height,Rotate" text-3xl>
<div class="i-carbon:arrow-up" />
Use the `v-drag` component to have a draggable container!
</v-drag>
When you create a new draggable element, you don't need to specify the position value (but you need to specify the position name if you want to use the frontmatter). Slidev will automatically generate the initial position value for you.
You can set Height to NaN (in) or _ (if you use the component) to make the height of the draggable element automatically adjust to its content.
Shift while dragging to preserve its aspect ratio.The <v-drag-arrow> component creates a draggable arrow element. Simply use it like this:
<v-drag-arrow />
And you will get a draggable arrow element. Other props are the same as the Arrow component.