Skip to content

FloatingPanel ​

Floating panel component: a fixed bottom panel dragged by its header and snapped to the nearest anchor on release. All anchor geometry (percentage conversion, nearest anchor, snap decision, drag clamping) consumes the pure functions from @lh-ui/share/core/floating-panel; the viewport height comes from @/adapter/platform (innerHeight on H5, windowHeight on mini-programs), with zero uni API in the component layer. Serves filtering, detail hosting and bottom action scenarios.

Platform differences (registered): the viewport height is read via the platform adapter (getLhWindowInfo: window.innerHeight on H5, uni.getWindowInfo().windowHeight on mini-programs); dragging is unified as touch events (identical on H5 and MP, coordinates from touches[0].clientY); the fixed positioning lives on the root node (the purified output of share styles/floating-panel), the height is carried by an inline style, and the --dragging modifier disables the transition during the drag for a finger-following feel.

Basic usage ​

Default anchors are [60, '40%'] (60px and 40% of the viewport height):

vue
<template>
  <lh-floating-panel>
    <view>Panel content</view>
  </lh-floating-panel>
</template>

Custom anchors ​

anchors is an array of heights: a number is px, a string like '40%' is a percentage of the viewport height; after release the panel snaps to the nearest anchor:

vue
<lh-floating-panel :anchors="[120, 320, 560]" @change="onChange" />

Controlled step (v-model) ​

Passing modelValue makes the panel controlled: pushing the step from outside syncs the panel height, and releasing a drag emits update:modelValue / change:

vue
<lh-floating-panel v-model="index" :anchors="[80, 400]" />

Header-only dragging ​

When contentDraggable (true by default) is false, only the header handle area responds to dragging and the content area (e.g. a scrolling list) no longer takes over the gesture:

vue
<lh-floating-panel :content-draggable="false" :anchors="[100, 300]">
  <scroll-view scroll-y>Long scrolling content</scroll-view>
</lh-floating-panel>

Disabled and safe area ​

vue
<lh-floating-panel disabled :anchors="[100, 300]" />
<lh-floating-panel :safe-area-inset-bottom="false" :anchors="[100, 300]" />

Custom header ​

The header slot replaces the default handle (the slot content remains the drag area):

vue
<lh-floating-panel :anchors="[100, 300]">
  <template #header>
    <view>Custom header</view>
  </template>
</lh-floating-panel>

Props ​

PropDescriptionTypeDefault
anchorsSnap height array (px numbers or 'percentage' strings)`(numberstring)[]`
modelValueCurrent snap step index (controlled)number—
contentDraggableContent area draggablebooleantrue
safeAreaInsetBottomBottom safe area insetbooleantrue
disabledDisable draggingbooleanfalse
customClassCustom class (forwarded to the root node)string—
sxsx quick layout propsLhSxProps—

Events ​

EventDescriptionCallback args
update:modelValueStep change (controlled sync)(index: number)
changeStep change after release-snap(index: number)
heightChangePanel height change (drag tracking + snap)(height: number)

Slots ​

SlotDescription
headerHeader drag area (renders the __handle bar by default)
defaultPanel content

Accessibility ​

The root node carries the role="region" semantics; aria-label is produced by share core's getFloatingPanelAria ("Floating panel step i / N" by default), and aria-disabled is set when disabled.