Animated CTA Buttons
Expanding Arrow Button
ExpandingArrowButton.vue<script setup lang="ts">
import { ExpandingArrowButton } from 'beui-vue'
</script>
<template><div class="arrow-demo"><ExpandingArrowButton>Book a demo</ExpandingArrowButton></div></template>
<style scoped>
.arrow-demo { display: flex; align-items: center; justify-content: center; }
</style><script setup lang="ts">
import { motion } from 'motion-v'
import { useReducedMotion } from '../core/reduced-motion'
import { shallowRef } from 'vue'
import { useMountedMedia } from '../core/mounted-media'
import { easeOut, layoutSpring, pressSpring } from '../core/motion'
const props = defineProps<{
disabled?: boolean
className?: string
accentClassName?: string
labelClassName?: string
}>()
// Arrow glyphs fade down the row: the accent chip fills with repeated dotted
// chevrons that are nearly opaque at the left and fade out to the right.
const ARROW_OPACITY = [1, .78, .54, .32, .16] as const
const reduce = useReducedMotion()
// Touch devices fire a sticky phantom hover; only a real pointer may expand it.
const canHover = useMountedMedia('(hover: hover) and (pointer: fine)')
const hovered = shallowRef(false)
const focused = shallowRef(false)
const active = () => !props.disabled && ((canHover.value && hovered.value) || focused.value)
</script>
<template>
<motion.button
type="button"
:disabled="disabled"
class="be-arrow-button"
:class="className"
:while-press="reduce || disabled ? undefined : { scale: .97 }"
:transition="pressSpring"
@mouseenter="hovered = true"
@mouseleave="hovered = false"
@focus="focused = true"
@blur="focused = false"
>
<!-- The accent pill grows from a 52px chip to fill the button. Layout size
keeps the corners and the inner row registered while it stretches. -->
<motion.span
layout="size"
aria-hidden="true"
class="be-arrow-accent"
:class="accentClassName"
:style="{ width: active() ? 'calc(100% - 12px)' : '52px', borderRadius: '16px' }"
:transition="reduce ? { duration: 0 } : layoutSpring"
>
<motion.span
class="be-arrow-glyph"
:animate="{ opacity: active() ? 0 : 1 }"
:transition="{ duration: reduce ? 0 : .1, ease: easeOut }"
>
<svg viewBox="0 0 20 28" fill="none" aria-hidden="true" class="be-arrow-chevron">
<circle cx="4" cy="4" r="2" fill="currentColor" /><circle cx="10" cy="9" r="2" fill="currentColor" />
<circle cx="16" cy="14" r="2" fill="currentColor" /><circle cx="10" cy="19" r="2" fill="currentColor" />
<circle cx="4" cy="24" r="2" fill="currentColor" />
</svg>
</motion.span>
<span class="be-arrow-row">
<motion.span
v-for="(opacity, index) in ARROW_OPACITY"
:key="opacity"
class="be-arrow-cell"
:animate="{ opacity: active() ? 1 : 0, transform: active() && !reduce ? 'translateX(0px)' : 'translateX(-6px)' }"
:transition="{
duration: reduce ? 0 : .18,
delay: active() && !reduce ? .04 + index * .025 : 0,
ease: easeOut,
}"
:style="{ color: `rgb(10 10 10 / ${opacity})` }"
>
<svg viewBox="0 0 20 28" fill="none" aria-hidden="true" class="be-arrow-chevron">
<circle cx="4" cy="4" r="2" fill="currentColor" /><circle cx="10" cy="9" r="2" fill="currentColor" />
<circle cx="16" cy="14" r="2" fill="currentColor" /><circle cx="10" cy="19" r="2" fill="currentColor" />
<circle cx="4" cy="24" r="2" fill="currentColor" />
</svg>
</motion.span>
</span>
</motion.span>
<motion.span
class="be-arrow-label"
:class="labelClassName"
:animate="{ opacity: active() ? 0 : 1, transform: active() && !reduce ? 'translateX(6px)' : 'translateX(0px)' }"
:transition="{ duration: reduce ? 0 : .12, ease: easeOut }"
>
<slot />
</motion.span>
</motion.button>
</template>
<style scoped>
.be-arrow-button {
position: relative; display: inline-flex; align-items: center; box-sizing: border-box;
height: 4rem; min-width: 18rem; overflow: hidden; border: 0; border-radius: 22px; padding: .375rem;
background: oklch(.145 0 0); color: #fff; font: inherit; cursor: pointer; user-select: none; outline: none;
}
.be-arrow-button:focus-visible { box-shadow: 0 0 0 2px var(--beui-background), 0 0 0 4px oklch(.897 .196 126.665); }
.be-arrow-button:disabled { pointer-events: none; opacity: .5; }
.be-arrow-accent {
position: absolute; inset-block: .375rem; inset-inline-start: .375rem; z-index: 10;
overflow: hidden; background: oklch(.897 .196 126.665); color: oklch(.145 0 0);
}
.be-arrow-glyph { position: absolute; inset: 0; display: grid; place-items: center; }
.be-arrow-row { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-around; padding-inline: .75rem; }
.be-arrow-cell { display: inline-grid; place-items: center; }
.be-arrow-chevron { width: 1.25rem; height: 1.75rem; }
.be-arrow-label {
position: relative; z-index: 0; margin-inline-start: 76px; margin-inline-end: 1.25rem;
white-space: nowrap; font-size: 1.125rem; line-height: 1.75rem; font-weight: 500; letter-spacing: -.02em;
}
</style>Install
Run it in a project set up with shadcn-vue. The source is copied to components/beui and its dependencies are added to your package.json. Read the shadcn-vue guide
$ bunx --bun shadcn-vue@latest add @beui-vue/expanding-arrow-button$ bun add beui-vueDownload the release archive to your project root, then install the local file.
$ bun add ./beui-vue-0.1.0.tgzImport the shared styles once in your application.
import ExpandingArrowButton from '@/components/beui/actions/ExpandingArrowButton.vue'
import '@/components/beui/styles.css'API Reference
className?string—accentClassName?string—labelClassName?string—disabled?boolean—Hold Action Button
HoldActionButton.vueRelease early to cancel
<script setup lang="ts">
import { HoldActionButton } from 'beui-vue'
import { onBeforeUnmount, shallowRef } from 'vue'
const confirmed = shallowRef(false)
let timer: ReturnType<typeof setTimeout> | undefined
function complete() {
confirmed.value = true
clearTimeout(timer)
timer = setTimeout(() => { confirmed.value = false }, 1800)
}
onBeforeUnmount(() => clearTimeout(timer))
</script>
<template>
<div class="hold-demo">
<HoldActionButton @hold-complete="complete">Hold for vertical fill</HoldActionButton>
<HoldActionButton type="horizontal" @hold-complete="complete">Hold for horizontal fill</HoldActionButton>
<p aria-live="polite">{{ confirmed ? 'Action confirmed' : 'Release early to cancel' }}</p>
</div>
</template>
<style scoped>
.hold-demo { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .75rem; }
.hold-demo p { height: 1rem; margin: 0; color: var(--beui-muted-foreground); font-size: .75rem; line-height: 1rem; }
</style><script setup lang="ts">
import { motion } from 'motion-v'
import { useReducedMotion } from '../core/reduced-motion'
import { computed, onBeforeUnmount, shallowRef, watch, type VNode } from 'vue'
import { easeOut, pressSpring } from '../core/motion'
import { capturePointer, releasePointer } from '../core/touch'
import { holdActionButtonMessages, type HoldActionButtonMessages } from './hold-action-messages'
const props = withDefaults(defineProps<{
/** Fill direction: bottom-up, or left-to-right. */
type?: 'vertical' | 'horizontal'
/** Alias kept for the existing Vue demos and docs: `horizontal` fills left-to-right. */
direction?: 'vertical' | 'horizontal'
holdingLabel?: string
completeLabel?: string
/** How long the fill takes to cross the button, in ms. */
holdDuration?: number
fillClassName?: string
labelClassName?: string
disabled?: boolean
className?: string
/** Override any built-in string. */
labels?: Partial<HoldActionButtonMessages>
}>(), { type: 'vertical', holdDuration: 1600 })
const emit = defineEmits<{ holdComplete: [] }>()
const slots = defineSlots<{
/** Resting label. A plain string also names the button for assistive technology. */
default?: () => VNode[]
/** Replaces the \"holding\" text; wins over the `holdingLabel` prop. */
holdingLabel?: () => VNode[]
/** Replaces the \"complete\" text; wins over the `completeLabel` prop. */
completeLabel?: () => VNode[]
}>()
const fillType = computed(() => props.direction ?? props.type)
const reduce = useReducedMotion()
const text = computed(() => ({ ...holdActionButtonMessages, ...props.labels }))
const holding = shallowRef(false)
const completed = shallowRef(false)
// React keeps this in a ref so the fill's completion callback cannot fire twice
// for one hold. A plain flag is enough here for the same reason.
let completedOnce = false
function startHold() {
if (props.disabled || holding.value) return
completedOnce = false
completed.value = false
holding.value = true
}
function cancelHold() {
holding.value = false
completed.value = false
}
function pointerDown(event: PointerEvent) {
if (event.button !== 0) return
// Start first: capture is a convenience, and a browser that refuses it must
// not take the hold down with it.
startHold()
capturePointer(event.currentTarget as Element, event.pointerId)
}
function pointerUp(event: PointerEvent) {
releasePointer(event.currentTarget as Element, event.pointerId)
cancelHold()
}
function pointerLeave(event: PointerEvent) {
// Only reached when the capture was refused: a captured pointer gets no
// boundary events at all. A finger does not get this reading either way —
// WebKit fires leave repeatedly for a touch that never moved, which would
// cancel every hold on the frame it started.
if (event.pointerType === 'touch') return
// Chrome fires a boundary `pointerleave` at the capture target as the capture
// is taken; before that is settled, a leave is only real when the pointer is
// actually off the button.
if ((event.currentTarget as Element).hasPointerCapture?.(event.pointerId)) return
const rect = (event.currentTarget as HTMLElement).getBoundingClientRect()
if (event.clientX < rect.left || event.clientX > rect.right || event.clientY < rect.top || event.clientY > rect.bottom) cancelHold()
}
function pointerMove(event: PointerEvent) {
// Leaving the button abandons the hold, and while the pointer is captured
// nothing announces that: no boundary events, and `touch-action: none` means
// a finger sliding off cannot scroll and so cannot cancel either. Measure it
// instead — off the button ends the hold, wherever the pointer then goes.
if (!holding.value) return
const rect = (event.currentTarget as HTMLElement).getBoundingClientRect()
if (event.clientX < rect.left || event.clientX > rect.right || event.clientY < rect.top || event.clientY > rect.bottom) cancelHold()
}
function keyDown(event: KeyboardEvent) {
if ((event.key === ' ' || event.key === 'Enter') && !event.repeat) {
event.preventDefault()
startHold()
}
}
function keyUp(event: KeyboardEvent) {
if (event.key === ' ' || event.key === 'Enter') {
event.preventDefault()
cancelHold()
}
}
function blur() {
// A key held while focus leaves never delivers its keyup here.
cancelHold()
}
function fillComplete() {
if (!holding.value || completedOnce) return
completedOnce = true
completed.value = true
emit('holdComplete')
}
watch(() => props.disabled, (value: boolean) => { if (value) cancelHold() })
onBeforeUnmount(cancelHold)
const active = computed(() => holding.value || completed.value)
// The fill is a CSS transition, not a keyframe run: the same linear ramp the
// original gets from a one-shot tween, but interruptible the instant the
// gesture ends, and the browser reports the end for us.
const fillDuration = computed(() => (active.value ? props.holdDuration : (reduce.value ? 150 : 240)))
const fillEase = computed(() => (active.value ? 'linear' : 'cubic-bezier(0.16, 1, 0.3, 1)'))
const fillStyle = computed(() => {
if (reduce.value) {
return {
opacity: active.value ? 1 : 0,
transform: 'none',
transition: `opacity ${fillDuration.value}ms ${fillEase.value}`,
}
}
return {
opacity: 1,
transform: active.value
? 'translate(0%)'
: (fillType.value === 'horizontal' ? 'translateX(-100%)' : 'translateY(115%)'),
transition: `transform ${fillDuration.value}ms ${fillEase.value}`,
}
})
function fillEnd(event: TransitionEvent) {
if (event.propertyName !== 'transform' && event.propertyName !== 'opacity') return
if (!active.value) return
fillComplete()
}
// The label is only a name when the slot is a plain string; a node label has to
// read itself, exactly as the original leaves `aria-label` undefined there.
const accessibleName = computed(() => {
const nodes = slots.default?.() ?? []
const [first] = nodes
return nodes.length === 1 && typeof first?.children === 'string' ? first.children : undefined
})
</script>
<template>
<motion.button
type="button"
:disabled="disabled"
:aria-label="accessibleName"
class="be-hold"
:class="className"
:while-press="reduce || disabled ? undefined : { scale: .98 }"
:transition="pressSpring"
@pointerdown="pointerDown"
@pointermove="pointerMove"
@pointerup="pointerUp"
@pointercancel="cancelHold"
@pointerleave="pointerLeave"
@keydown="keyDown"
@keyup="keyUp"
@blur="blur"
@contextmenu.prevent
>
<!-- Safari hands the fill its own compositing layer and then stops applying
the button's rounded overflow clip to it, so the liquid bleeds past the
corners. clip-path survives compositing. It lives on this static layer
rather than the button so it never cuts the focus ring. -->
<span aria-hidden="true" class="be-hold-clip">
<span aria-hidden="true" class="be-hold-fill" :class="fillClassName" :style="fillStyle" @transitionend="fillEnd">
<!-- A band of liquid rides the fill's edge; it keeps sliding while held and
eases back to rest when the hold ends, like the original. -->
<motion.svg
v-if="!reduce && fillType === 'horizontal'"
viewBox="0 0 24 240"
preserveAspectRatio="none"
aria-hidden="true"
class="be-hold-wave be-hold-wave-horizontal"
:animate="{ transform: active ? 'translateY(-50%)' : 'translateY(0%)' }"
:transition="{ duration: 1.1, ease: 'linear', repeat: active ? Infinity : 0 }"
>
<path d="M0 0h12C2 20 2 40 12 60s10 40 0 60-10 40 0 60 10 40 0 60H0Z" fill="currentColor" />
</motion.svg>
<motion.svg
v-else-if="!reduce"
viewBox="0 0 240 24"
preserveAspectRatio="none"
aria-hidden="true"
class="be-hold-wave be-hold-wave-vertical"
:animate="{ transform: active ? 'translateX(-50%)' : 'translateX(0%)' }"
:transition="{ duration: 1.1, ease: 'linear', repeat: active ? Infinity : 0 }"
>
<path d="M0 12C20 2 40 2 60 12s40 10 60 0 40-10 60 0 40 10 60 0v12H0Z" fill="currentColor" />
</motion.svg>
</span>
</span>
<span class="be-hold-label" :class="labelClassName">
<motion.span
class="be-hold-slot"
:animate="{ opacity: active ? 0 : 1 }"
:transition="{ duration: reduce ? 0 : .12, ease: easeOut }"
><slot /></motion.span>
<motion.span
class="be-hold-slot"
:aria-hidden="!(holding && !completed)"
:animate="{ opacity: holding && !completed ? 1 : 0 }"
:transition="{ duration: reduce ? 0 : .12, ease: easeOut }"
><slot name="holdingLabel">{{ holdingLabel ?? text.holding }}</slot></motion.span>
<motion.span
class="be-hold-slot"
:aria-hidden="!completed"
:animate="{ opacity: completed ? 1 : 0 }"
:transition="{ duration: reduce ? 0 : .12, ease: easeOut }"
><slot name="completeLabel">{{ completeLabel ?? text.complete }}</slot></motion.span>
</span>
</motion.button>
</template>
<style scoped>
.be-hold {
--hold-radius: 22px;
position: relative; display: inline-grid; box-sizing: border-box; place-items: center;
width: auto; height: 4rem; min-width: 18rem; overflow: hidden; padding-inline: 2rem;
border: 0; border-radius: var(--hold-radius); background: var(--beui-primary);
color: var(--beui-primary-foreground, #fff); font: inherit; cursor: pointer; outline: none;
touch-action: none; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none;
}
.be-hold:focus-visible { box-shadow: 0 0 0 2px var(--beui-background), 0 0 0 4px var(--beui-primary); }
.be-hold:disabled { pointer-events: none; opacity: .5; }
.be-hold-clip {
pointer-events: none; position: absolute; inset: 0;
clip-path: inset(0 round var(--hold-radius));
}
.be-hold-fill {
position: absolute; inset: 0; background: oklch(74.6% .16 232.661); will-change: opacity, transform;
}
.be-hold-wave { position: absolute; color: oklch(74.6% .16 232.661); will-change: transform; }
.be-hold-wave-vertical { left: 0; top: -1.25rem; width: 200%; height: 1.5rem; }
.be-hold-wave-horizontal { top: 0; right: -1.25rem; width: 1.5rem; height: 200%; }
.be-hold-label {
position: relative; z-index: 10; display: grid; place-items: center;
font-size: 1rem; font-weight: 500; letter-spacing: -.01em;
}
.be-hold-slot { grid-area: 1 / 1; }
</style>Install
Run it in a project set up with shadcn-vue. The source is copied to components/beui and its dependencies are added to your package.json. Read the shadcn-vue guide
$ bunx --bun shadcn-vue@latest add @beui-vue/hold-action-button$ bun add beui-vueDownload the release archive to your project root, then install the local file.
$ bun add ./beui-vue-0.1.0.tgzImport the shared styles once in your application.
import HoldActionButton from '@/components/beui/actions/HoldActionButton.vue'
import '@/components/beui/styles.css'API Reference
type?"vertical" | "horizontal"Fill direction: bottom-up, or left-to-right.
verticalclassName?string—labels?Partial<HoldActionButtonMessages>Override any built-in string.
—labelClassName?string—holdingLabel?string—completeLabel?string—holdDuration?numberHow long the fill takes to cross the button, in ms.
1600@hold-complete?() => void—fillClassName?string—direction?"vertical" | "horizontal"Alias kept for the existing Vue demos and docs: `horizontal` fills left-to-right.
—disabled?boolean—#default?slotResting label. A plain string also names the button for assistive technology.
—#holdingLabel?slotReplaces the \"holding\" text; wins over the `holdingLabel` prop.
—#completeLabel?slotReplaces the \"complete\" text; wins over the `completeLabel` prop.
—Slide Action Button
SlideActionButton.vueDrag the arrow to the end
<script setup lang="ts">
import { onBeforeUnmount, ref } from 'vue'
import { SlideActionButton } from 'beui-vue'
const continued = ref(false)
let timer: ReturnType<typeof setTimeout> | undefined
function complete() {
continued.value = true
clearTimeout(timer)
timer = setTimeout(() => { continued.value = false }, 1800)
}
onBeforeUnmount(() => clearTimeout(timer))
</script>
<template>
<div class="slide-demo">
<SlideActionButton complete-label="Ready" @complete="complete">Slide to continue</SlideActionButton>
<p aria-live="polite">{{ continued ? 'Action completed' : 'Drag the arrow to the end' }}</p>
</div>
</template>
<style scoped>
.slide-demo { display: flex; flex-direction: column; align-items: center; gap: .75rem; }
p { height: 1rem; margin: 0; font-size: .75rem; line-height: 1rem; color: var(--beui-muted-foreground); }
</style><script setup lang="ts">
import { animate, motion, useMotionValue, useMotionValueEvent, useTransform } from 'motion-v'
import { useReducedMotion } from '../core/reduced-motion'
import { computed, onBeforeUnmount, onMounted, shallowRef, useTemplateRef, type VNode } from 'vue'
import { easeOut, layoutSpring, pressSpring } from '../core/motion'
import { capturePointer, releasePointer } from '../core/touch'
import { slideActionButtonMessages, type SlideActionButtonMessages } from './slide-action-messages'
const props = withDefaults(defineProps<{
/** Track label; the slot wins when both are set. */
label?: string
disabled?: boolean
completeLabel?: string
/** Fraction of the track the thumb must reach to complete. */
threshold?: number
/** How long the completed state lasts before the thumb slides back, in ms. A negative value keeps it. */
resetDelay?: number
thumbClassName?: string
fillClassName?: string
className?: string
/** Override any built-in string. */
labels?: Partial<SlideActionButtonMessages>
}>(), { threshold: .82, resetDelay: 1200 })
const emit = defineEmits<{ complete: [] }>()
const slots = defineSlots<{
/** Track label. A plain string also names the thumb for assistive technology. */
default?: () => VNode[]
/** Shown on the track once the slide completes; wins over the `completeLabel` prop. */
completeLabel?: () => VNode[]
}>()
const reduce = useReducedMotion()
const text = computed(() => ({ ...slideActionButtonMessages, ...props.labels }))
// `<motion.button>` is a component, so its template ref is the component
// instance rather than the element; unwrap `$el` once and keep the node.
const trackRef = useTemplateRef<HTMLElement>('track')
const thumbRef = useTemplateRef<{ $el?: Element } | HTMLElement>('thumb')
const trackElement = computed(() => trackRef.value)
const thumbElement = computed<HTMLElement | null>(() => {
const raw = thumbRef.value
if (!raw) return null
return ((raw as { $el?: HTMLElement }).$el ?? raw) as HTMLElement
})
const maxDistance = shallowRef(0)
const completed = shallowRef(false)
let completedOnce = false
let resetTimer: ReturnType<typeof setTimeout> | undefined
let dragging = false
let grabX = 0
let startX = 0
// One motion value drives the thumb; the fill, label fade and glyph morph are
// derived from it by hand so they stay exactly in step with the drag even as the
// measured track width changes under a resize.
const ICONS = [
'M 8 5 L 15 12 L 8 19',
'M 7 8 L 12 14 L 17 10',
'M 5 12 L 10 17 L 19 7',
] as const
// The chevron folds into a check as the thumb travels: two segment paths,
// interpolated so the glyph morphs instead of swapping glyphs.
const x = useMotionValue(0)
// Progress (0-1 along the track) drives the fill, the label fade and the glyph
// morph through motion transforms, exactly like the upstream useTransform chain.
const progress = useMotionValue(0)
const labelOpacity = useTransform(progress, [0, .35, .65], [1, .75, 0])
const iconPath = useTransform(progress, [0, .5, 1], [...ICONS])
function sync(value: number) {
const safe = Math.max(maxDistance.value, 1)
progress.set(Math.min(1, Math.max(0, value / safe)))
}
useMotionValueEvent(x, 'change', sync)
function moveTo(target: number) {
if (reduce.value) {
x.set(target)
return
}
animate(x, target, layoutSpring)
}
function reset() {
completedOnce = false
completed.value = false
moveTo(0)
}
function complete() {
if (props.disabled || completedOnce || maxDistance.value === 0) return
completedOnce = true
completed.value = true
moveTo(maxDistance.value)
emit('complete')
clearTimeout(resetTimer)
if (props.resetDelay >= 0) resetTimer = setTimeout(reset, props.resetDelay)
}
function pointerDown(event: PointerEvent) {
if (props.disabled || completed.value || event.button !== 0) return
dragging = true
startX = event.clientX
grabX = x.get()
capturePointer(event.currentTarget as Element, event.pointerId)
}
function pointerMove(event: PointerEvent) {
if (!dragging) return
x.set(Math.max(0, Math.min(maxDistance.value, grabX + event.clientX - startX)))
}
function pointerUp(event: PointerEvent) {
if (!dragging) return
dragging = false
releasePointer(event.currentTarget as Element, event.pointerId)
if (x.get() >= maxDistance.value * props.threshold) complete()
else moveTo(0)
}
function keyDown(event: KeyboardEvent) {
if (event.key !== 'Enter' && event.key !== ' ') return
event.preventDefault()
complete()
}
const accessibleName = computed(() => {
const nodes = slots.default?.() ?? []
const [first] = nodes
if (nodes.length === 1 && typeof first?.children === 'string') return first.children
return props.label ?? text.value.thumbLabel
})
let observer: ResizeObserver | undefined
function measure() {
const track = trackElement.value
const thumb = thumbElement.value
if (!track || !thumb) return
maxDistance.value = Math.max(track.clientWidth - thumb.clientWidth - 8, 0)
sync(x.get())
}
onMounted(() => {
measure()
observer = new ResizeObserver(measure)
if (trackElement.value) observer.observe(trackElement.value)
if (thumbElement.value) observer.observe(thumbElement.value)
})
onBeforeUnmount(() => {
observer?.disconnect()
clearTimeout(resetTimer)
})
</script>
<template>
<div ref="track" class="be-slide" :class="className">
<motion.span aria-hidden="true" class="be-slide-fill" :class="fillClassName" :style="{ scaleX: progress }" />
<motion.span aria-hidden="true" class="be-slide-label" :style="{ opacity: labelOpacity }">
<slot>{{ label }}</slot>
</motion.span>
<motion.span
aria-live="polite"
class="be-slide-complete"
:animate="{ opacity: completed ? 1 : 0 }"
:transition="{ duration: reduce ? 0 : .15, ease: easeOut }"
><slot v-if="completed" name="completeLabel">{{ completeLabel ?? text.complete }}</slot></motion.span>
<motion.button
ref="thumb"
type="button"
:aria-label="accessibleName"
:disabled="disabled"
class="be-slide-thumb"
:class="[thumbClassName, { 'is-complete': completed }]"
:style="{ x }"
:while-press="reduce || completed ? undefined : { scale: .94 }"
:transition="pressSpring"
@pointerdown="pointerDown"
@pointermove="pointerMove"
@pointerup="pointerUp"
@pointercancel="pointerUp"
@keydown="keyDown"
>
<motion.svg viewBox="0 0 24 24" aria-hidden="true" class="be-slide-glyph">
<motion.path
:d="iconPath"
fill="none"
stroke="currentColor"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
/>
</motion.svg>
</motion.button>
</div>
</template>
<style scoped>
.be-slide {
position: relative; box-sizing: border-box; height: 4rem; width: 18rem; max-width: 100%;
overflow: hidden; border-radius: 22px; padding: .25rem; background: var(--beui-muted);
box-shadow: 0 0 0 1px color-mix(in srgb, var(--beui-primary) 10%, transparent);
-webkit-touch-callout: none;
}
@media (pointer: coarse) { .be-slide { user-select: none; -webkit-user-select: none; } }
.be-slide-fill {
position: absolute; inset: 0; transform-origin: left; will-change: transform;
background: var(--beui-primary);
}
.be-slide-label {
pointer-events: none; position: absolute; inset: 0; display: grid; place-items: center;
padding-left: 2.5rem; color: var(--beui-foreground); font-size: .875rem; line-height: 1.25rem; font-weight: 500;
}
.be-slide-complete {
pointer-events: none; position: absolute; inset: 0; display: grid; place-items: center;
color: var(--beui-primary-foreground, #fff); font-size: .875rem; line-height: 1.25rem; font-weight: 500;
}
.be-slide-thumb {
position: relative; z-index: 10; display: grid; place-items: center; width: 3.5rem; height: 3.5rem;
border: 0; border-radius: 18px; background: var(--beui-primary);
color: var(--beui-primary-foreground, #fff); box-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);
cursor: grab; touch-action: none; outline: none;
-webkit-touch-callout: none; user-select: none; -webkit-user-select: none;
}
.be-slide-thumb:active { cursor: grabbing; }
.be-slide-thumb:focus-visible { box-shadow: 0 0 0 2px var(--beui-background), 0 0 0 4px var(--beui-primary); }
.be-slide-thumb:disabled { pointer-events: none; opacity: .5; }
.be-slide-thumb.is-complete { cursor: default; background: var(--beui-background); color: var(--beui-foreground); }
.be-slide-glyph { width: 1.25rem; height: 1.25rem; pointer-events: none; outline: none; }
</style>Install
Run it in a project set up with shadcn-vue. The source is copied to components/beui and its dependencies are added to your package.json. Read the shadcn-vue guide
$ bunx --bun shadcn-vue@latest add @beui-vue/slide-action-button$ bun add beui-vueDownload the release archive to your project root, then install the local file.
$ bun add ./beui-vue-0.1.0.tgzImport the shared styles once in your application.
import SlideActionButton from '@/components/beui/actions/SlideActionButton.vue'
import '@/components/beui/styles.css'API Reference
completeLabel?string—threshold?numberFraction of the track the thumb must reach to complete.
.82resetDelay?numberHow long the completed state lasts before the thumb slides back, in ms. A negative value keeps it.
1200@complete?() => void—thumbClassName?string—fillClassName?string—labels?Partial<SlideActionButtonMessages>Override any built-in string.
—className?string—label?stringTrack label; the slot wins when both are set.
—disabled?boolean—#default?slotTrack label. A plain string also names the thumb for assistive technology.
—#completeLabel?slotShown on the track once the slide completes; wins over the `completeLabel` prop.
—Related components
Action Swap
CTA button and slot primitives for swapping text and icons with blur motion.
Expandable Control
Click-to-expand button and chip controls that reveal a label or trailing action through spring layout continuity.
Card
Composable card with header, title, description, action, content and footer parts. Outlined or muted surfaces, standard or compact spacing, and an opt-in selectable state with press feedback that composes with Checkbox, Radio and Button.
Updated