@douxcode/vue-spring-bottom-sheet

中文文档
3.2.0发布于 2026/03/24MITTypeScriptESM + CJS构建来源已验证近 30 天下载 6503

Modern and Performant Bottom Sheet for Vue.js

原始使用文档
文档目录11 节
  1. Basic usage
  2. Basic usage setup + TS
  3. Usage with v-model
  4. Usage in Nuxt 3
  5. Slots
  6. CSS Custom Properties
  7. Props
  8. Prop Definitions
  9. Exposed methods
  10. Events
  11. Acknowledgments

Vue Spring Bottom Sheet

😎 Modern and 🚀 Performant Bottom Sheet for Vue.js

Demo 👀

Installation

npm install @douxcode/vue-spring-bottom-sheet
bun install @douxcode/vue-spring-bottom-sheet

Getting started

Basic usage

<script setup>
import BottomSheet from '@douxcode/vue-spring-bottom-sheet'
import '@douxcode/vue-spring-bottom-sheet/dist/style.css'
import { useTemplateRef } from 'vue'

const bottomSheet = useTemplateRef('bottomSheet')

const open = () => {
  bottomSheet.value.open()
}

const close = () => {
  bottomSheet.value.close()
}
</script>

<template>
  <BottomSheet ref="bottomSheet"> Your awesome content </BottomSheet>
</template>

Basic usage setup + TS

<script setup lang="ts">
import BottomSheet from '@douxcode/vue-spring-bottom-sheet'
import '@douxcode/vue-spring-bottom-sheet/dist/style.css'
import { ref } from 'vue'

const bottomSheet = ref<InstanceType<typeof BottomSheet>>()

/* For vue 3.5+ you can use useTemplateRef() */
const bottomSheet = useTemplateRef('bottomSheet')

const open = () => {
  bottomSheet.value.open()
}

const close = () => {
  bottomSheet.value.close()
}
</script>

<template>
  <BottomSheet ref="bottomSheet"> Your content </BottomSheet>
</template>

Usage with v-model

<script setup lang="ts">
import { ref } from 'vue'

import BottomSheet from '@douxcode/vue-spring-bottom-sheet'
import '@douxcode/vue-spring-bottom-sheet/dist/style.css'

const sheet = ref(false)
</script>

<template>
  <button type="button" @click="sheet = true">Open bottom sheet</button>
  <BottomSheet v-model="sheet"> Your content </BottomSheet>
</template>

Usage in Nuxt 3

For Nuxt 3, just wrap component in <ClientOnly>

<template>
  <ClientOnly>
    <BottomSheet ref="bottomSheet"> Your awesome content </BottomSheet>
  </ClientOnly>
</template>

Slots

<template>
  <BottomSheet ref="bottomSheet">
    <template #header> Header </template>
    <div>Your content</div>
    <template #footer> Footer </template>
  </BottomSheet>
</template>

CSS Custom Properties

--vsbs-backdrop-bg: rgba(0, 0, 0, 0.5);
--vsbs-shadow-color: rgba(89, 89, 89, 0.2);
--vsbs-background: #fff;
--vsbs-border-radius: 16px;
--vsbs-outer-border-color: transparent;
--vsbs-max-width: 640px;
--vsbs-border-color: rgba(46, 59, 66, 0.125);
--vsbs-padding-x: 16px;
--vsbs-handle-background: rgba(0, 0, 0, 0.28);

Props

Prop Definitions

PropTypeDefaultDescription
durationNumber250Animation duration in milliseconds
snapPointsArray<number|${number}%>[instinctHeight]Custom snapping positions
initialSnapPointNumberminHeightInitial snap point index
blockingBooleantrueBlock interactions with underlying content
canSwipeCloseBooleantrueEnable swipe-to-close gesture
swipeCloseThresholdNumber|${number}%"50%"The amount of translation (in px or %) after which the element will close
canBackdropCloseBooleantrueAllow closing by tapping backdrop
expandOnContentDragBooleantrueEnable expanding by dragging content
teleportToString | RendererElementbodyTeleport to a specific element
teleportDeferBooleanfalseDefer teleporting until opened (Vue 3.5+ only)
headerClassString''Set header element class
contentClassString''Set content element class
footerClassString''Set footer element class
forceMountBooleanfalseForce mount the bottom sheet in the DOM

Interactive content inside the sheet body keeps its native touch behavior. Inputs and editable content do not start sheet dragging, and custom widgets can opt out with data-vsbs-no-drag.

Exposed methods

Assuming there is const bottomSheet = ref()

MethodDescriptionExample
openOpens the bottom sheetbottomSheet.value.open()
closeCloses the bottom sheetbottomSheet.value.close()
snapToPointSnaps to an index of snapPointsbottomSheet.value.snapToPoint(1)

Events

EventDescriptionPayload
openedEmitted when sheet finishes opening-
opening-startedEmitted when sheet starts opening-
closedEmitted when sheet finishes closing-
closing-startedEmitted when sheet starts closing-
dragging-upEmitted when user drags sheet upward-
dragging-downEmitted when user drags sheet downward-
instinctHeightEmitted when content height changesheight (number)
snappedEmitted when sheet finishes snappingsnapPointIndex (number)

Acknowledgments

This project was inspired by the following:

版本与发布记录

@douxcode/vue-spring-bottom-sheet 共发布 49 个版本,首次发布于 2024/12/26;过去 12 个月发布了 10 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
3.2.0latest2026/03/247 个月前
3.1.02026/03/098 个月前
3.0.02026/02/079 个月前
3.0.0-next.6next2026/02/079 个月前
3.0.0-next.52026/01/239 个月前
3.0.0-next.42026/01/159 个月前

关于 @douxcode/vue-spring-bottom-sheet 的常见问题

@douxcode/vue-spring-bottom-sheet 是什么?

Modern and Performant Bottom Sheet for Vue.js

如何安装 @douxcode/vue-spring-bottom-sheet?

在项目目录运行 npm install @douxcode/vue-spring-bottom-sheet,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:vue(>=3.3)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@douxcode/vue-spring-bottom-sheet 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@douxcode/vue-spring-bottom-sheet 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@douxcode/vue-spring-bottom-sheet 可以商用吗?

@douxcode/vue-spring-bottom-sheet 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@douxcode/vue-spring-bottom-sheet 的下载量有多少?

根据 npm 官方下载统计,@douxcode/vue-spring-bottom-sheet 在 2026/10/13 – 2026/11/11 这 30 天内被下载 6,503 次,日均约 217 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@douxcode/vue-spring-bottom-sheet 还在维护吗?

最新版本 3.2.0 发布于 2026/03/24(7 个月前);至今共发布 49 个版本,其中过去 12 个月发布了 10 个;首次发布于 2024/12/26。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。