/*! 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:'

FloatingPanel

\n

Intro

\n

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.

\n

Install

\n

Register component globally via app.use, refer to Component Registration for more registration ways.

\n
import { createApp } from 'vue';\nimport { FloatingPanel } from 'vant';\n\nconst app = createApp();\napp.use(FloatingPanel);\n
\n

Usage

\n

Basic Usage

\n

The default height of FloatingPanel is 100px, and users can drag it to expand the panel to a height of 60% of the screen height.

\n
<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
\n

Custom Anchors

\n

You can set the anchor position of FloatingPanel through the anchors attribute, and control the display height of the current panel through v-model:height.

\n

For example, you can make the panel stop at three positions: 100px, 40% of the screen height, and 70% of the screen height.

\n
<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
\n
import { 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
\n

Head Drag Only

\n

By 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.

\n
<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
\n

API

\n

Props

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeDescriptionTypeDefault
v-model:heightThe current display height of the panelnumber | string0
anchorsSetting custom anchors, unit pxnumber[][100, window.innerWidth * 0.6]
durationTransition duration, unit secondnumber | string0.3
content-draggableAllow dragging contentbooleantrue
lock-scroll v4.6.4When not dragging, Whether to lock background scrollbooleanfalse
safe-area-inset-bottomWhether to enable bottom safe area adaptationbooleantrue
\n

Events

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
EventDescriptionArguments
height-changeEmitted when panel height is changed and the dragging is finished{ height: number }
\n

Slots

\n\n\n\n\n\n\n\n\n\n\n\n\n\n
NameDescription
defaultCustom panel content
\n

Types

\n

The component exports the following type definitions:

\n
import type { FloatingPanelProps } from 'vant';\n
\n

Theming

\n

CSS Variables

\n

The component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
NameDefault ValueDescription
--van-floating-panel-border-radius16px-
--van-floating-panel-header-height30px-
--van-floating-panel-z-index999-
--van-floating-panel-backgroundvar(--van-background-2)-
--van-floating-panel-bar-width20px-
--van-floating-panel-bar-height3px-
--van-floating-panel-bar-colorvar(--van-gray-5)-
\n
'},null,8,e))}}}]);