/*! For license information please see 7558.15185332.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["7558"],{71175:function(n,a,s){"use strict";s.r(a);var t=s("80681");let e=["innerHTML"];a.default={setup:()=>({html:""}),render:()=>((0,t.wg)(),(0,t.iD)("div",{class:"van-doc-markdown-body",innerHTML:'
A panel that floats at the bottom of a page, which can be dragged up and down to browse content, often used to provide additional functionality or information. Please upgrade vant
to >= v4.5.0 before using this component.
Register component globally via app.use
, refer to Component Registration for more registration ways.
import { createApp } from 'vue';\nimport { FloatingPanel } from 'vant';\n\nconst app = createApp();\napp.use(FloatingPanel);\n
\nThe default height of FloatingPanel is 100px
, and users can drag it to expand the panel to a height of 60%
of the screen height.
<van-floating-panel>\n <van-cell-group>\n <van-cell\n v-for="i in 26"\n :key="i"\n :title="String.fromCharCode(i + 64)"\n size="large"\n />\n </van-cell-group>\n</van-floating-panel>\n
\nYou can set the anchor position of FloatingPanel through the anchors
attribute, and control the display height of the current panel through v-model:height
.
For example, you can make the panel stop at three positions: 100px
, 40% of the screen height, and 70% of the screen height.
<van-floating-panel v-model:height="height" :anchors="anchors">\n <div style="text-align: center; padding: 15px">\n <p>Panel Show Height {{ height.toFixed(0) }} px</p>\n </div>\n</van-floating-panel>\n
\nimport { ref } from 'vue';\n\nexport default {\n setup() {\n const anchors = [\n 100,\n Math.round(0.4 * window.innerHeight),\n Math.round(0.7 * window.innerHeight),\n ];\n const height = ref(anchors[0]);\n\n return { anchors, height };\n },\n};\n
\nBy default, both the header and content areas of FloatingPanel can be dragged, but you can disable dragging of the content area through the content-draggable
attribute.
<van-floating-panel :content-draggable="false">\n <div style="text-align: center; padding: 15px">\n <p>Content cannot be dragged</p>\n </div>\n</van-floating-panel>\n
\nAttribute | \nDescription | \nType | \nDefault | \n
---|---|---|---|
v-model:height | \nThe current display height of the panel | \nnumber | string | \n0 | \n
anchors | \nSetting custom anchors, unit px | \nnumber[] | \n[100, window.innerWidth * 0.6] | \n
duration | \nTransition duration, unit second | \nnumber | string | \n0.3 | \n
content-draggable | \nAllow dragging content | \nboolean | \ntrue | \n
lock-scroll v4.6.4 | \nWhen not dragging, Whether to lock background scroll | \nboolean | \nfalse | \n
safe-area-inset-bottom | \nWhether to enable bottom safe area adaptation | \nboolean | \ntrue | \n
Event | \nDescription | \nArguments | \n
---|---|---|
height-change | \nEmitted when panel height is changed and the dragging is finished | \n{ height: number } | \n
Name | \nDescription | \n
---|---|
default | \nCustom panel content | \n
The component exports the following type definitions:
\nimport type { FloatingPanelProps } from 'vant';\n
\nThe component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.
\nName | \nDefault Value | \nDescription | \n
---|---|---|
--van-floating-panel-border-radius | \n16px | \n- | \n
--van-floating-panel-header-height | \n30px | \n- | \n
--van-floating-panel-z-index | \n999 | \n- | \n
--van-floating-panel-background | \nvar(--van-background-2) | \n- | \n
--van-floating-panel-bar-width | \n20px | \n- | \n
--van-floating-panel-bar-height | \n3px | \n- | \n
--van-floating-panel-bar-color | \nvar(--van-gray-5) | \n- | \n