Fab 悬浮按钮
业务组件
悬浮在页面右下角的圆形操作按钮,用于最主要的创建/新增操作。
何时使用
需要悬浮按钮功能时使用本组件。
代码示例
基础用法
tsx
import { Fab, FabSpeedDial, BackTop } from "@/components/business/fab"
export function Basic() {
return (
<Fab>
<FabSpeedDial>Content</FabSpeedDial>
</Fab>
)
}API / Props
Fab
| Prop | Type | Default | 说明 |
|---|---|---|---|
className | string | — | 自定义样式类名 |
icon | React.ReactNode | — | 图标元素 |
label | string | — | 标签文本 |
position | "bottom-right" | "bottom-left" | "b... | bottom-right | |
offset | number | 4 | 偏移量 |
| ...rest | React.HTMLAttributes | — | 透传原生 DOM 属性 |
注意事项
- Client Component: 使用
"use client",依赖 React hooks/状态,需在客户端渲染。 - 复合组件: 包含 1 个子组件(FabSpeedDial),使用组合模式按需导入。
📘 完整交互式示例与控件属性请查看 Storybook 文档。