
Floating Action Button React 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 React component represents Floating Action Button element.
FAB Components
There are following components included:
**Fab**/**F7Fab**- main FAB element**FabButtons**/**F7FabButtons**- wrapper for multiple FAB buttons used as Speed Dial FAB**FabButton**/**F7FabButton**- single FAB Speed Dial button
FAB Properties
| Prop | Type | Default | Description |
|---|---|---|---|
| <Fab> properties | |||
| --- | --- | --- | --- |
| href | string 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 |
|
| target | string | Value of link target attribute, e.g. _blank, _self, etc. |
|
| position | string | right-bottom | FAB 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 |
| morphTo | string | String CSS selector of the FAB morph target | |
| text | string | FAB Button text. If specified, then it will be displayed as Extended Fab with text label | |
| tooltip | string | FAB tooltip text to show on button hover/press | |
| <FabButtons> properties | |||
| position | string | top | Speed 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 |
| <FabButton> properties | |||
| fabClose | boolean | false | When enabled then clicking on this button will close the FAB |
| target | string | Value of link target attribute, e.g. _blank, _self, etc. |
|
| label | string | Button text label | |
| tooltip | string | Button tooltip text to show on button hover/press |
FAB Events
| Event | Description |
|---|---|
| <Fab> events | |
| --- | --- |
| click | Event will be triggered after click on FAB |
| <FabButton> events | |
| click | Event will be triggered after click on FAB Speed Dial button |
FAB Slots
FAB React component (<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 isFabButtons, 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. export default () => (
2. <Page>
3. <Navbar title="Floating Action Button" />
5. {/* Toolbar FAB Morph Target */}
6. <Toolbar bottomMd className="fab-morph-target">
7. <Link>Link 1</Link>
8. <Link>Link 2</Link>
9. <Link>Link 3</Link>
10. </Toolbar>
12. {/* FAB Left Top (Yellow) */}
13. <Fab position="left-top" slot="fixed" color="yellow">
14. <Icon ios="f7:add" md="material:add"></Icon>
15. <Icon ios="f7:close" md="material:close"></Icon>
16. <FabButtons position="bottom">
17. <FabButton>1</FabButton>
18. <FabButton>2</FabButton>
19. <FabButton>3</FabButton>
20. </FabButtons>
21. </Fab>
23. {/* FAB Right Top (Pink) */}
24. <Fab position="right-top" slot="fixed" color="pink">
25. <Icon ios="f7:add" md="material:add"></Icon>
26. <Icon ios="f7:close" md="material:close"></Icon>
27. <FabButtons position="left">
28. <FabButton>1</FabButton>
29. <FabButton>2</FabButton>
30. <FabButton>3</FabButton>
31. </FabButtons>
32. </Fab>
34. {/* FAB Center (Green) */}
35. <Fab position="center-center" slot="fixed" color="green">
36. <Icon ios="f7:add" md="material:add"></Icon>
37. <Icon ios="f7:close" md="material:close"></Icon>
38. <FabButtons position="center">
39. <FabButton>1</FabButton>
40. <FabButton>2</FabButton>
41. <FabButton>3</FabButton>
42. <FabButton>4</FabButton>
43. </FabButtons>
44. </Fab>
46. {/* FAB Left Bottom (Blue) */}
47. {/* Will morph to Toolbar */}
48. <Fab position="left-bottom" slot="fixed" morphTo=".toolbar.fab-morph-target">
49. <Icon ios="f7:add" md="material:add"></Icon>
50. <Icon ios="f7:close" md="material:close"></Icon>
51. </Fab>
53. {/* FAB Right Bottom (Orange) */}
54. <Fab position="right-bottom" slot="fixed" color="orange">
55. <Icon ios="f7:add" md="material:add"></Icon>
56. <Icon ios="f7:close" md="material:close"></Icon>
57. <FabButtons position="top">
58. <FabButton label="Action 1">1</FabButton>
59. <FabButton label="Action 2">2</FabButton>
60. </FabButtons>
61. </Fab>
63. {/* Extended FAB Center Bottom (Red) */}
64. <Fab position="center-bottom" slot="fixed" text="Create" color="red">
65. <Icon ios="f7:add" md="material:add"></Icon>
66. </Fab>
68. <Block>
69. <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quia, quo rem beatae, delectus eligendi est saepe molestias ... voluptatibus eligendi.</p>
70. </Block>
71. </Page>
72. )
