Skip to content

FloatingPanel Floating Panel

A panel floating at the bottom of the page. Users can drag the panel up and down to browse content, allowing access to more information without leaving the current view. Commonly used for map navigation.

Component Type

Basic Usage

The initial height of FloatingPanel takes the value of anchors[0], which is 100px. Users can drag to expand the panel to reach 60% of the screen height.

html
<wd-floating-panel>
  <wd-cell-group border>
    <wd-cell v-for="item in data" :key="item" :title="item" />
  </wd-cell-group>
</wd-floating-panel>
ts
import { ref } from 'vue'

const data = ref<string[]>(['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'])

Component Variants

Custom Anchors

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

For example, to make the panel height dock at three positions: 100px, 40% of screen height, and 70% of screen height:

html
<wd-floating-panel v-model:height="height" :anchors="anchors" @heightChange="handleHeightChange">
  <view class="inner-content">Custom Anchors {{ anchors }} - {{ height.toFixed(0) }}</view>
</wd-floating-panel>
ts
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'

const height = ref<number>(0)
const windowHeight = ref<number>(0)
const anchors = ref<number[]>([])

const handleHeightChange = ({ height }: { height: number }) => {
  console.log(height)
}

onLoad(() => {
  windowHeight.value = uni.getSystemInfoSync().windowHeight
  anchors.value = [100, Math.round(0.4 * windowHeight.value), Math.round(0.7 * windowHeight.value)]
  height.value = anchors.value[1]
})
css
.inner-content {
  padding: 1rem;
  text-align: center;
  font-size: 16px;
  font-weight: bold;
}

Component State

Header Drag Only

By default, both the header area and content area of FloatingPanel can be dragged. You can disable dragging of the content area via the contentDraggable attribute.

html
<wd-floating-panel :content-draggable="false">
  <view class="inner-content">Content area cannot be dragged</view>
</wd-floating-panel>
css
.inner-content {
  padding: 1rem;
  text-align: center;
  font-size: 16px;
  font-weight: bold;
}

Attributes

ParameterDescriptionTypeDefault Value
v-model:height v1.3.12Current display height of the panelnumber0
anchors v1.3.12Set custom anchors, unit pxnumber[][100, windowHeight * 0.6]
duration v1.3.12Animation duration, unit ms. Set to 0 to disable animationnumber300
content-draggable v1.3.12Allow dragging content containerbooleantrue
safe-area-inset-bottom v1.3.12Whether to enable bottom safe area adaptationbooleanfalse
show-scrollbar v1.3.12Whether to enable scrollbarbooleantrue
custom-classCustom class name for root nodestring''
custom-styleCustom style for root nodestring''

Slots

NameDescription
defaultDefault content area slot v1.3.12

Events

Method NameDescriptionParameters
heightChangeTriggered after panel display height changes and dragging ends v1.3.12{ height: number }

主题定制

CSS 变量

组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 ConfigProvider 全局配置

名称默认值描述
--wot-floating-panel-bg$filled-oppo面板背景色
--wot-floating-panel-radius$radius-large面板圆角
--wot-floating-panel-z-index99面板 z-index
--wot-floating-panel-header-height$n-32头部高度
--wot-floating-panel-bar-width$n-36拖拽条宽度
--wot-floating-panel-bar-height$n-4拖拽条高度
--wot-floating-panel-bar-bg$filled-strong拖拽条背景色
--wot-floating-panel-bar-radius$radius-main拖拽条圆角
--wot-floating-panel-content-bg$filled-oppo内容区域背景色

Source Code

Documentation
Component

Released under the MIT License.

Released under the MIT License.