TAYUN 9132174b11
docs: ✏️ 修复基础组件文档问题 - 阶段一完成 (#1220)
* docs(button): 更新按钮组件文档对开放能力的描述

- 修改 session-message-title 和 session-message-path 属性名称
- 新增 chooseavatar 和 agreeprivacyauthorization 事件回调

* docs(icon): 更新图标组件文档

- 调整属性描述,明确 name 属性可用于图标名称或图片链接
- 添加事件列表,明确 click 事件的参数
- 移除英文示例代码中不必要的示例和图标列表
- 优化文档结构和格式,使信息更加清晰

* docs(config-provider): 更新全局配置组件文档

- 调整文档中的强调样式,使用加粗替代下划线
- 完善英文文档缺失的内容,保持和中文文档一致

* docs(component): 更新 Popup 组件文档

- 调整文档结构,优化标题层级
- 添加 v-model 使用示例,明确组件绑定值
- 移除冗余的代码示例,精简文档内容
- 更新属性表格,统一属性描述
- 添加防止滚动穿透的解决方案说明

* docs(resize):  ✏️ 更新 resize 组件文档

- 修正事件名称从 `size` 改为 `resize`
- 添加组件属性(Attributes)、事件(Events)和插槽(Slots)的详细说明
- 更新文档结构,使其更加完整和易于理解

* docs(transition): ✏️完善Transition 动画组件文档的属性和事件描述

- 增加自定义根节点样式类、懒渲染、动画结束后销毁子节点等属性
- 添加进入和离开过渡的开始、激活和结束状态类
- 新增点击事件和默认插槽
- 更新文档以反映新增功能

* docs(fab): ✏️更新fab组件文档

- 优化了文档结构,调整了部分格式
- 添加了 Methods 和 default Slot 相关的信息
- 更新了 custom-style 属性的命名

* docs(component): ✏️ 更新 Text 组件文档

- 优化文档格式,调整表格结构
- 添加缺失的参数说明和示例代码
- 更新参数类型和默认值
- 增加 call 参数说明
- 补充 Slots 表格

* docs(root-portal):  ✏️ 更新组件文档

- 添加 Attributes 和 Events 部分,说明该组件无相关配置
- 修正 Slots 部分的版本信息,统一为 1.11.0
- 更新中文和英文文档
2025-08-17 14:08:48 +08:00

9.4 KiB

Fab Floating Action Button

Floating action button component that displays a group of action buttons when pressed.

:::warning Since uni-app components cannot monitor clicks outside themselves, to automatically close the fab when clicking elsewhere on the page, it is recommended to use the component library's useQueue hook (which will close all dropmenu, popover, toast, swipeAction, fab). Monitor click event bubbling on the root element of the page.

If there is a scenario where the user manually clicks somewhere other than fab to slide out the fab, you need to add click.stop="" to the clicked element (in this case, the button) to prevent event bubbling to the root element, avoiding triggering closeOutside which would close the manually opened fab. :::

Basic Usage

Set the trigger type through type, set the trigger position through position, set the opening direction of action buttons through direction, and set whether the floating button is disabled through disabled.

<wd-fab :disabled="disabled" :type="type" :position="position" :direction="direction">
  <wd-button @click="showToast('Triple Like')" :disabled="disabled" custom-class="custom-button" type="primary" round>
    <wd-icon name="github-filled" size="22px"></wd-icon>
  </wd-button>
  <wd-button @click="showToast('Add to Favorites')" :disabled="disabled" custom-class="custom-button" type="success" round>
    <wd-icon name="star" size="22px"></wd-icon>
  </wd-button>

  <wd-button @click="showToast('Give Coin')" :disabled="disabled" custom-class="custom-button" type="error" round>
    <wd-icon name="money-circle" size="22px"></wd-icon>
  </wd-button>
  <wd-button @click="showToast('Like')" :disabled="disabled" custom-class="custom-button" type="warning" round>
    <wd-icon name="thumb-up" size="22px"></wd-icon>
  </wd-button>
</wd-fab>
import { useToast } from '@/uni_modules/wot-design-uni'
const { show: showToast } = useToast()
const type = ref<'primary' | 'success' | 'info' | 'warning' | 'error' | 'default'>('primary')
const position = ref<'left-top'
  | 'right-top'
  | 'left-bottom'
  | 'right-bottom'
  | 'left-center'
  | 'right-center'
  | 'top-center'
  | 'bottom-center'>('left-bottom')
const direction = ref<'top' | 'right' | 'bottom' | 'left'>('top')
const disabled = ref<boolean>(false)
:deep(.custom-button) {
  min-width: auto !important;
  box-sizing: border-box;
  width: 32px !important;
  height: 32px !important;
  border-radius: 16px !important;
  margin: 8rpx;
}

:deep(.custom-radio) {
  height: 32px !important;
  line-height: 32px !important;
}

Action Menu Expand/Collapse

Control the expansion/collapse of the action button menu through v-model:active

<wd-fab v-model:active="active"></wd-fab>
const active = ref<boolean>(false)

Draggable Button

<wd-fab :draggable="true"></wd-fab>

:::warning After enabling dragging, the direction property will be invalid, and the pop-up direction will be automatically calculated based on the position after dragging. After dragging is completed, the button will automatically snap to the edge. :::

Custom Trigger

Customize the trigger through the trigger slot, expandable controls whether clicking the trigger expands/collapses the action button menu.

<wd-fab position="left-bottom" :expandable="false">
  <template #trigger>
    <wd-button @click="handleClick" icon="share" type="error">Share with Friends</wd-button>
  </template>
</wd-fab>
const handleClick = () => {
  console.log('Clicked')
}

Attributes

Parameter Description Type Options Default Value Version
v-model:active Whether activated boolean - false 0.1.57
type Type FabType 'primary' | 'success' | 'info' | 'warning' | 'error' | 'default' 'primary' 0.1.57
position Floating button position FabPosition 'left-top' | 'right-top' | 'left-bottom' | 'right-bottom' | left-center | right-center | top-center | bottom-center 'right-bottom' 0.1.57
draggable Whether button can be dragged boolean - false 1.2.19
direction Floating button menu pop-up direction FabDirection 'top' | 'right' | 'bottom' | 'left' 'top' 0.1.57
disabled Whether disabled boolean - false 0.1.57
inactiveIcon Icon when floating button is not expanded string - 'add' 0.1.57
activeIcon Icon when floating button is expanded string - 'close' 0.1.57
zIndex Custom floating button layer level number - 99 0.1.57
gap Custom gap between floating button and viewport edges FabGap - { top: 16, left: 16, right: 16, bottom: 16 } 1.2.26
custom-style Custom style string - '' 0.1.57
expandable Controls whether to expand menu when clicked, triggers click when set to false boolean - true 1.3.11

Events

Event Name Description Parameters Version
click Triggered when clicking the floating button when expandable is false 1.3.11

Methods

Method Name Description Parameters Version
open Expand menu - 0.1.57
close Collapse menu - 0.1.57

Slot

name Description Version
default Action buttons, usually contains multiple buttons 0.1.57
trigger Trigger slot, used for custom click button, component won't emit click when using this slot 1.3.11

External Classes

Class Name Description Version
custom-class Custom style class 0.1.57