Floating Action Button / FAB - 图1

Floating Action Button Vue Component

Floating action buttons (FABs) are used for a promoted action. They are distinguished by a circled icon floating above the UI and have motion behaviors that include morphing, launching, and a transferring anchor point.

Floating Action Button Vue component represents Floating Action Button element.

FAB Components

There are following components included:

  • **f7-fab** - main FAB element
  • **f7-fab-buttons** - wrapper for multiple FAB buttons used as Speed Dial FAB
  • **f7-fab-button** - single FAB Speed Dial button

FAB Properties

PropTypeDefaultDescription
<f7-fab> properties
hrefstring
boolean
URL of the page to load (if set). Will set href attribute on main FAB link. In case of boolean href=”false” it won’t add href tag
targetstringValue of link target attribute, e.g. _blank, _self, etc.
positionstringright-bottomFAB position. Can be one of the following:
  • right-bottom
  • center-bottom
  • left-bottom
  • right-center
  • center-center
  • left-center
  • right-top
  • center-top
  • left-top
morph-tostringString CSS selector of the FAB morph target
textstringFAB Button text. If specified, then it will be displayed as Extended Fab with text label
tooltipstringFAB tooltip text to show on button hover/press
<f7-fab-buttons> properties
positionstringtopSpeed dial buttons position, can be one of the following:
  • top - buttons will appear on top of FAB
  • right - buttons will appear on right of FAB
  • bottom - buttons will appear on bottom of FAB
  • left - buttons will appear on left of FAB
  • center - buttons will appear around of FAB
<f7-fab-button> properties
fab-closebooleanfalseWhen enabled then clicking on this button will close the FAB
targetstringValue of link target attribute, e.g. _blank, _self, etc.
labelstringButton text label
tooltipstringButton tooltip text to show on button hover/press

FAB Events

EventDescription
<f7-fab> events
clickEvent will be triggered after click on FAB
<f7-fab-button> events
clickEvent will be triggered after click on FAB Speed Dial button

FAB Slots

FAB Vue component (<f7-fab>) has additional slots for custom elements:

  • **default** - child element will be inserted inside of the main FAB link <a> element. But if the child is f7-fab-buttons, then it will be inserted in the end of the main FAB element
  • **link** - child element will be inserted inside of the main FAB link <a> element
  • **root** - child element will be inserted in the end of the main FAB element
  • **text** - child element will be inserted in the text element of the Extended FAB

Examples

  1. <f7-page>
  2. <f7-navbar title="Floating Action Button"></f7-navbar>
  3. <!-- Toolbar FAB Morph Target -->
  4. <f7-toolbar bottom-md class="fab-morph-target">
  5. <f7-link>Link 1</f7-link>
  6. <f7-link>Link 2</f7-link>
  7. <f7-link>Link 3</f7-link>
  8. </f7-toolbar>
  9. <!-- FAB Left Top (Yellow) -->
  10. <f7-fab position="left-top" slot="fixed" color="yellow">
  11. <f7-icon ios="f7:add" md="material:add"></f7-icon>
  12. <f7-icon ios="f7:close" md="material:close"></f7-icon>
  13. <f7-fab-buttons position="bottom">
  14. <f7-fab-button>1</f7-fab-button>
  15. <f7-fab-button>2</f7-fab-button>
  16. <f7-fab-button>3</f7-fab-button>
  17. </f7-fab-buttons>
  18. </f7-fab>
  19. <!-- FAB Right Top (Pink) -->
  20. <f7-fab position="right-top" slot="fixed" color="pink">
  21. <f7-icon ios="f7:add" md="material:add"></f7-icon>
  22. <f7-icon ios="f7:close" md="material:close"></f7-icon>
  23. <f7-fab-buttons position="left">
  24. <f7-fab-button>1</f7-fab-button>
  25. <f7-fab-button>2</f7-fab-button>
  26. <f7-fab-button>3</f7-fab-button>
  27. </f7-fab-buttons>
  28. </f7-fab>
  29. <!-- FAB Center (Green) -->
  30. <f7-fab position="center-center" slot="fixed" color="green">
  31. <f7-icon ios="f7:add" md="material:add"></f7-icon>
  32. <f7-icon ios="f7:close" md="material:close"></f7-icon>
  33. <f7-fab-buttons position="center">
  34. <f7-fab-button>1</f7-fab-button>
  35. <f7-fab-button>2</f7-fab-button>
  36. <f7-fab-button>3</f7-fab-button>
  37. <f7-fab-button>4</f7-fab-button>
  38. </f7-fab-buttons>
  39. </f7-fab>
  40. <!-- FAB Left Bottom (Blue) -->
  41. <!-- Will morph to Toolbar -->
  42. <f7-fab position="left-bottom" slot="fixed" morph-to=".toolbar.fab-morph-target">
  43. <f7-icon ios="f7:add" md="material:add"></f7-icon>
  44. <f7-icon ios="f7:close" md="material:close"></f7-icon>
  45. </f7-fab>
  46. <!-- FAB Right Bottom (Orange) -->
  47. <f7-fab position="right-bottom" slot="fixed" color="orange">
  48. <f7-icon ios="f7:add" md="material:add"></f7-icon>
  49. <f7-icon ios="f7:close" md="material:close"></f7-icon>
  50. <f7-fab-buttons position="top">
  51. <f7-fab-button label="Action 1">1</f7-fab-button>
  52. <f7-fab-button label="Action 2">2</f7-fab-button>
  53. </f7-fab-buttons>
  54. </f7-fab>
  55. <!-- Extended FAB Center Bottom (Red) -->
  56. <f7-fab position="center-bottom" slot="fixed" text="Create" color="red">
  57. <f7-icon ios="f7:add" md="material:add"></f7-icon>
  58. </f7-fab>
  59. <f7-block>
  60. <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quia, quo rem beatae, delectus eligendi est saepe molestias ... voluptatibus eligendi.</p>
  61. </f7-block>
  62. </f7-page>