2022-09-23 14:31:16 +08:00
|
|
|
|
---
|
|
|
|
|
category: Components
|
2023-08-08 19:48:41 +08:00
|
|
|
|
group: General
|
2022-09-23 14:31:16 +08:00
|
|
|
|
title: FloatButton
|
2022-11-30 20:14:41 +08:00
|
|
|
|
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*HS-wTIIwu0kAAAAAAAAAAAAADrJ8AQ/original
|
2023-02-09 22:17:31 +08:00
|
|
|
|
coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*a0hwTY_rOSUAAAAAAAAAAAAADrJ8AQ/original
|
2022-11-09 12:28:04 +08:00
|
|
|
|
demo:
|
|
|
|
|
cols: 2
|
2023-08-08 19:48:41 +08:00
|
|
|
|
tag: New
|
2022-09-23 14:31:16 +08:00
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
FloatButton. Available since `5.0.0`.
|
|
|
|
|
|
|
|
|
|
## When To Use
|
|
|
|
|
|
|
|
|
|
- For global functionality on the site.
|
|
|
|
|
- Buttons that can be seen wherever you browse.
|
|
|
|
|
|
2022-11-09 12:28:04 +08:00
|
|
|
|
## Examples
|
|
|
|
|
|
2022-11-17 17:31:26 +08:00
|
|
|
|
<!-- prettier-ignore -->
|
2022-11-17 11:30:20 +08:00
|
|
|
|
<code src="./demo/basic.tsx" iframe="360">Basic</code>
|
|
|
|
|
<code src="./demo/type.tsx" iframe="360">Type</code>
|
|
|
|
|
<code src="./demo/shape.tsx" iframe="360">Shape</code>
|
|
|
|
|
<code src="./demo/description.tsx" iframe="360">Description</code>
|
|
|
|
|
<code src="./demo/tooltip.tsx" iframe="360">FloatButton with tooltip</code>
|
|
|
|
|
<code src="./demo/group.tsx" iframe="360">FloatButton Group</code>
|
|
|
|
|
<code src="./demo/group-menu.tsx" iframe="360">Menu mode</code>
|
2023-06-12 17:20:55 +08:00
|
|
|
|
<code src="./demo/controlled.tsx" iframe="360">Controlled mode</code>
|
2022-11-17 11:30:20 +08:00
|
|
|
|
<code src="./demo/back-top.tsx" iframe="360">BackTop</code>
|
2023-03-20 10:28:20 +08:00
|
|
|
|
<code src="./demo/badge.tsx" iframe="360">badge</code>
|
|
|
|
|
<code src="./demo/badge-debug.tsx" iframe="360" debug>debug dot</code>
|
2022-11-09 12:28:04 +08:00
|
|
|
|
<code src="./demo/render-panel.tsx" debug>\_InternalPanelDoNotUseOrYouWillBeFired</code>
|
|
|
|
|
|
2022-09-23 14:31:16 +08:00
|
|
|
|
## API
|
|
|
|
|
|
2023-08-08 18:27:48 +08:00
|
|
|
|
Common props ref:[Common props](/docs/react/common-props)
|
|
|
|
|
|
2022-11-27 17:39:35 +08:00
|
|
|
|
> This component is available since `antd@5.0.0`.
|
|
|
|
|
|
2022-09-23 14:31:16 +08:00
|
|
|
|
### common API
|
|
|
|
|
|
2022-11-17 17:31:26 +08:00
|
|
|
|
| Property | Description | Type | Default | Version |
|
|
|
|
|
| --- | --- | --- | --- | --- |
|
|
|
|
|
| icon | Set the icon component of button | ReactNode | - | |
|
|
|
|
|
| description | Text and other | ReactNode | - | |
|
|
|
|
|
| tooltip | The text shown in the tooltip | ReactNode \| () => ReactNode | | |
|
|
|
|
|
| type | Setting button type | `default` \| `primary` | `default` | |
|
|
|
|
|
| shape | Setting button shape | `circle` \| `square` | `circle` | |
|
|
|
|
|
| onClick | Set the handler to handle `click` event | (event) => void | - | |
|
|
|
|
|
| href | The target of hyperlink | string | - | |
|
|
|
|
|
| target | Specifies where to display the linked URL | string | - | |
|
2023-03-21 14:11:39 +08:00
|
|
|
|
| badge | Attach Badge to FloatButton. `status` and other props related are not supported. | [BadgeProps](/components/badge#api) | - | 5.4.0 |
|
2022-09-23 14:31:16 +08:00
|
|
|
|
|
|
|
|
|
### FloatButton.Group
|
|
|
|
|
|
2022-11-17 17:31:26 +08:00
|
|
|
|
| Property | Description | Type | Default | Version |
|
|
|
|
|
| --- | --- | --- | --- | --- |
|
|
|
|
|
| shape | Setting button shape of children | `circle` \| `square` | `circle` | |
|
|
|
|
|
| trigger | Which action can trigger menu open/close | `click` \| `hover` | - | |
|
2023-06-12 17:20:55 +08:00
|
|
|
|
| open | Whether the menu is visible or not, use it with trigger | boolean | - | |
|
|
|
|
|
| onOpenChange | Callback executed when active menu is changed, use it with trigger | (open: boolean) => void | - | |
|
2022-09-23 14:31:16 +08:00
|
|
|
|
|
|
|
|
|
### FloatButton.BackTop
|
|
|
|
|
|
2022-11-17 17:31:26 +08:00
|
|
|
|
| Property | Description | Type | Default | Version |
|
|
|
|
|
| --- | --- | --- | --- | --- |
|
|
|
|
|
| duration | Time to return to top(ms) | number | 450 | |
|
|
|
|
|
| target | Specifies the scrollable area dom node | () => HTMLElement | () => window | |
|
|
|
|
|
| visibilityHeight | The BackTop button will not show until the scroll height reaches this value | number | 400 | |
|
|
|
|
|
| onClick | A callback function, which can be executed when you click the button | () => void | - | |
|
2023-04-11 10:25:24 +08:00
|
|
|
|
|
|
|
|
|
## Design Token
|
|
|
|
|
|
|
|
|
|
<ComponentTokenTable component="FloatButton"></ComponentTokenTable>
|