Skip to content

FloatButton Floating Button Component ​

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

📌 Platform Compatibility ​

APP(vue)H5WeChat Mini ProgramAlipay Mini Program
✔✔✔✔

🏯 Basic Usage Examples ​

html
<!-- Global usage -->
<hy-float-button></hy-float-button>

FloatButton Default Button ​

html
<template>
    <hy-float-button
        text="Customer Service"
        :icon="IconConfig.CUSTOMER_SERVICE"
        iconSize="25"
    ></hy-float-button>
</template>

FloatButton Displaying a Menu Bar ​

html
<template>
    <hy-float-button :menus="menus_1"></hy-float-button>
    <hy-float-button :menus="menus_2"></hy-float-button>
</template>

<script setup>
    const menus_1 = ['Menu 1', 'Menu 2', 'Menu 3'];
    const menus_2 = [
        { label: 'Menu 1', url: '/pages/keFu/index' },
        { label: 'Menu 2' },
        { label: 'Menu 3' },
    ];
</script>

FloatButton Size ​

  • Set the size of the floating button via size
    • small: small button
    • medium: medium button
    • large: large button
    • Enter a number or a number with a unit to customize the button size
html
<template>
    <hy-float-button size="small"></hy-float-button>
    <hy-float-buttton size="medium"></hy-float-buttton>
    <hy-float-buttton size="large"></hy-float-buttton>
    <hy-float-buttton :size="20"></hy-float-buttton>
    <hy-float-buttton size="50rpx"></hy-float-buttton>
</template>

FloatButton Shape ​

  • Set different shapes of the floating button via shape
    • circle: circle
    • square: square
html
<template>
    <hy-float-button shape="circle"></hy-float-button>
    <hy-float-buttton shape="square"></hy-float-buttton>
</template>

FloatButton Opening Direction ​

  • Set the direction in which the floating button expands via direction
    • column: expands upward
    • row: expands horizontally

Note

When displayed horizontally, the menu expands to the right by default. If the left value is greater than half the screen width, the menu will expand to the left instead.

html
<template>
    <hy-float-button :menus="menus" direction="column"></hy-float-button>
    <hy-float-button :menus="menus" direction="row"></hy-float-button>
    <hy-float-button :menus="menus" left="80vw" direction="row"></hy-float-button>
</template>

<script setup>
    const menus = ['Menu 1', 'Menu 2', 'Menu 3'];
</script>

Whether to Float ​

  • Set whether the floating button floats via float
html
<template>
    <hy-float-button :float="true"></hy-float-button>
</template>

Show Shadow ​

  • Set whether the floating button displays a shadow via shadow
html
<template>
    <hy-float-button :shadow="true"></hy-float-button>
</template>

Set Opacity ​

  • Set the opacity of the floating button via opacity
html
<template>
    <hy-float-button :opacity="0.1"></hy-float-button>
</template>

API ​

FloatButton Props ​

ParameterDescriptionTypeDefault Value
menusCollection of menu items(string|AnyObject)[]-
directionOpening direction[1]row|columncolumn
iconIcon displayed on the buttonstringPLUS
iconSizeButton icon size; numbers use px by defaultnumber|string-
iconColorButton icon colorstring#FFFFFF
gapSpacing between the floating button and the edge of the viewport; numbers use px by defaultObject{ left: 16, right: 16, top: 16, bottom: 40 }
zIndexStacking levelnumber10086
bgColorButton background colorstring-
textButton textstring-
fontSizeButton text size; numbers use px by defaultnumber|string12px
textColorButton text colorstring-
sizeButton size[2]stringmedium
shapeButton shape[3]circle|squarecircle
opacityButton opacitynumber1
shadowWhether to display a shadowbooleantrue
floatWhether to show the floating animationbooleantrue
fixedWhether the position is fixedbooleantrue
draggableWhether the floating button can be draggedbooleantrue
positionFloating button position[4]string'right-bottom'
expandableControls whether the menu expands on clickbooleantrue
customStyleCustom external styles to be appliedCSSProperties-
customClassCustom external class namestring-

gap ​

ParameterDescriptionTypeDefault Value
leftMinimum distance from the left edgenumber16
rightMinimum distance from the right edgenumber16
topMinimum distance from the top edgenumber16
bottomMinimum distance from the bottom edgenumber40

Events ​

Event NameDescriptionCallback Parameters
clickButton is clicked-
clickItemMenu item is clickedtemp: menu item data, index: index

Slots ​

Slot NameDescriptionAccepted Value
defaultButton content-

CSS Variables ​

VariableDescriptionDefault Value
--hy-float-button-radiusButton border radiusFollows --hy-radius-sm (8rpx)
--hy-float-button-menus-max-heightMaximum height of the menu250px
--hy-float-button-menu-font-sizeMenu font sizeFollows --hy-font-size-base (28rpx)
12:33
battery

  1. row: horizontal; column: vertical ↩︎

  2. circle: semicircles on both sides; square: square with rounded corners ↩︎

  3. normal: default size; large: large size; small: small size; number: any size; ↩︎

  4. left-top: top-left; left-bottom: bottom-left; right-top: top-right; right-bottom: bottom-right; left-center: middle-left; right-center: middle-right; top-center: top-center; bottom-center: bottom-center; ↩︎