vael-ui v0.5.7

Gestures

Layout

SwipeToReveal

A row you swipe to reveal actions underneath it, like a native mobile list row. Use it for actions such as archive or delete on touch screens.

Install

import { SwipeToReveal } from 'vael-ui'

Playground

SwipeToReveal
Usage
<script setup lang="ts">
import { ref } from 'vue'
import { SwipeToReveal } from 'vael-ui'

const open = ref(false)
</script>

<template>
  <SwipeToReveal v-model:open="open">SwipeToReveal</SwipeToReveal>
</template>

Props

NameTypeDefaultDescription
disabledbooleanfalseBlocks swiping. reveal(), close() and v-model:open still work.
motionSwipeToRevealMotiontrueHow it moves: its appearance ({ initial: { root: { opacity: 0, y: 4 } } }) and its states ({ states: { open: { actions: { opacity: 1 } } } }). The built-in release and settle transition plays unless it's false, so you can drive the settle yourself.
revealScalenumber | booleantrueGrows the actions panel in from its edge as it opens. A number from 0 to 1 sets the starting scale. false turns it off.
uiPartial<Record<'root' | 'content' | 'actions', UiPartValue>>Class and style overrides for each part.
openbooleanfalseWhether an action panel is open. Setting it true opens the trailing edge, or the leading one if it's the only edge.

Events

NameTypeDescription
update:open(value: boolean)Fires when open changes (v-model:open).
change(open: boolean, side: SwipeRevealSide | null)Fires once per settled interaction, with open and the open edge (or null).

Slots

NameTypeDescription
default{ open: boolean; openSide: SwipeRevealSide | null; reveal: (side?: SwipeRevealSide | undefined) => void; close: () => void; }Row content that slides to reveal the actions.
leading-actions{ open: boolean; close: () => void; progress: number; }Leading-edge actions (left in LTR). progress goes from 0 to 1 as this edge opens.
trailing-actions{ open: boolean; close: () => void; progress: number; }Trailing-edge actions (right in LTR). progress goes from 0 to 1 as this edge opens.

Exposed

NameTypeDescription
elHTMLElement | nullRoot element.
contentElHTMLElement | nullSliding content element.
leadingActionsElHTMLElement | nullLeading actions panel (null without #leading-actions).
trailingActionsElHTMLElement | nullTrailing actions panel (null without #trailing-actions).
isDraggingbooleanWhether you're swiping. Taps don't count.
openSideSwipeRevealSide | nullWhich edge is open, or null when closed.
leadingProgressnumberReveal progress of the leading edge, from 0 to 1, as it is on screen.
trailingProgressnumberReveal progress of the trailing edge, from 0 to 1, as it is on screen.
reveal(side?: SwipeRevealSide | undefined) => voidOpens an edge. Without side, it opens the trailing edge, or the leading one if it's the only edge.
close() => voidCloses the open edge.
partsRecord<string, HTMLElement | HTMLElement[] | null>Its elements by part name, for your own animation; a repeated part is an array.

Motion New

SwipeToReveal: its appearance and states.

<SwipeToReveal
  :motion="{ states: { open: { root: { scale: 1.04 } } } }"
/>
NameTypeDescription
initialexitrootcontentactionsSets where each part comes in from and leaves to: any CSS property, plus x, y and blur. A plain number is px, or degrees for rotate.
statesopendraggingSets values per part that hold while a state is on. An array is a set of keyframes that plays once as the state turns on, such as a shake on invalid.
enterleave(parts, context) => animationAnimates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted.
springdurationeasing{ damping, response } | number | stringTimes all of it: a spring, or a duration in ms with an easing. Never both.
falsebooleanTurns its motion off, for an animation of your own on its exposed elements.

Accessibility

KeyAction
TabShiftTabReveals an actions panel when focus moves into it, and closes it when focus leaves the row.
EscapeCloses an open row without closing a dialog around it.
  • Both actions panels stay mounted and in the tab order while closed, so every action is reachable without swiping.
  • In the DOM, the leading actions come before the row content and the trailing actions after it, so Tab follows the screen.
  • Swiping is pointer only. Use v-model:open, reveal() or close() to open the actions another way.
  • With disabled, the root gets aria-disabled="true", and only swiping is blocked.