Floating Action Button / FAB - 图1

Floating Action Button Svelte 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 Svelte component represents Floating Action Button element.

FAB Components

There are following components included:

  • Fab - main FAB element
  • FabButtons - wrapper for multiple FAB buttons used as Speed Dial FAB
  • FabButton - single FAB Speed Dial button
  • FabBackdrop - FAB backdrop element

FAB Properties

PropTypeDefaultDescription
<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
morphTostringString 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
tooltipTriggerstringhoverDefines how to trigger (open) Tooltip. Can be hover or click. If hover tooltip will be toggled on mouse hover on desktop, and with tap and hold on touch devices
<FabButtons> 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
<FabButton> properties
fabClosebooleanfalseWhen 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
tooltipTriggerstringhoverDefines how to trigger (open) Tooltip. Can be hover or click. If hover tooltip will be toggled on mouse hover on desktop, and with tap and hold on touch devices

FAB Events

EventDescription
<Fab> events
clickEvent will be triggered after click on FAB
<FabButton> events
clickEvent will be triggered after click on FAB Speed Dial button

FAB Slots

FAB Svelte 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 is FabButtons, 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. <Page>
  2. <Navbar title="Floating Action Button" />
  3. <Toolbar bottom class="fab-morph-target">
  4. <Link>Link 1</Link>
  5. <Link>Link 2</Link>
  6. <Link>Link 3</Link>
  7. </Toolbar>
  8. <Fab position="left-top" color="yellow">
  9. <Icon ios="f7:plus" aurora="f7:plus" md="material:add"></Icon>
  10. <Icon ios="f7:xmark" aurora="f7:xmark" md="material:close"></Icon>
  11. <FabButtons position="bottom">
  12. <FabButton>1</FabButton>
  13. <FabButton>2</FabButton>
  14. <FabButton>3</FabButton>
  15. </FabButtons>
  16. </Fab>
  17. <Fab position="right-top" color="pink">
  18. <Icon ios="f7:plus" aurora="f7:plus" md="material:add"></Icon>
  19. <Icon ios="f7:xmark" aurora="f7:xmark" md="material:close"></Icon>
  20. <FabButtons position="left">
  21. <FabButton>1</FabButton>
  22. <FabButton>2</FabButton>
  23. <FabButton>3</FabButton>
  24. </FabButtons>
  25. </Fab>
  26. <Fab position="center-center" color="green">
  27. <Icon ios="f7:plus" aurora="f7:plus" md="material:add"></Icon>
  28. <Icon ios="f7:xmark" aurora="f7:xmark" md="material:close"></Icon>
  29. <FabButtons position="center">
  30. <FabButton>1</FabButton>
  31. <FabButton>2</FabButton>
  32. <FabButton>3</FabButton>
  33. <FabButton>4</FabButton>
  34. </FabButtons>
  35. </Fab>
  36. <Fab position="left-bottom" morphTo=".toolbar.fab-morph-target">
  37. <Icon ios="f7:plus" aurora="f7:plus" md="material:add"></Icon>
  38. <Icon ios="f7:xmark" aurora="f7:xmark" md="material:close"></Icon>
  39. </Fab>
  40. <Fab position="right-bottom" color="orange">
  41. <Icon ios="f7:plus" aurora="f7:plus" md="material:add"></Icon>
  42. <Icon ios="f7:xmark" aurora="f7:xmark" md="material:close"></Icon>
  43. <FabButtons position="top">
  44. <FabButton label="Action 1">1</FabButton>
  45. <FabButton label="Action 2">2</FabButton>
  46. </FabButtons>
  47. </Fab>
  48. <Fab position="center-bottom" text="Create" color="red">
  49. <Icon ios="f7:plus" aurora="f7:plus" md="material:add"></Icon>
  50. </Fab>
  51. <Block>
  52. <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quia, quo rem beatae, delectus eligendi est saepe molestias perferendis suscipit, commodi labore ipsa non quasi eum magnam neque ducimus! Quasi, numquam.</p>
  53. <p>Maiores culpa, itaque! Eaque natus ab cum ipsam numquam blanditiis a, quia, molestiae aut laudantium recusandae ipsa. Ad iste ex asperiores ipsa, mollitia perferendis consectetur quam eaque, voluptate laboriosam unde.</p>
  54. <p>Sed odit quis aperiam temporibus vitae necessitatibus, laboriosam, exercitationem dolores odio sapiente provident. Accusantium id, itaque aliquam libero ipsum eos fugiat distinctio laboriosam exercitationem sequi facere quas quidem magnam reprehenderit.</p>
  55. <p>Pariatur corporis illo, amet doloremque. Ab veritatis sunt nisi consectetur error modi, nam illo et nostrum quia aliquam ipsam vitae facere voluptates atque similique odit mollitia, rerum placeat nobis est.</p>
  56. <p>Et impedit soluta minus a autem adipisci cupiditate eius dignissimos nihil officia dolore voluptatibus aperiam reprehenderit esse facilis labore qui, officiis consectetur. Ipsa obcaecati aspernatur odio assumenda veniam, ipsum alias.</p>
  57. </Block>
  58. <Block>
  59. <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Culpa ipsa debitis sed nihil eaque dolore cum iste quibusdam, accusamus doloribus, tempora quia quos voluptatibus corporis officia at quas dolorem earum!</p>
  60. <p>Quod soluta eos inventore magnam suscipit enim at hic in maiores temporibus pariatur tempora minima blanditiis vero autem est perspiciatis totam dolorum, itaque repellat? Nobis necessitatibus aut odit aliquam adipisci.</p>
  61. <p>Tenetur delectus perspiciatis ex numquam, unde corrupti velit! Quam aperiam, animi fuga veritatis consectetur, voluptatibus atque consequuntur dignissimos itaque, sint impedit cum cumque at. Adipisci sint, iusto blanditiis ullam? Vel?</p>
  62. <p>Dignissimos velit officia quibusdam! Eveniet beatae, aut, omnis temporibus consequatur expedita eaque aliquid quos accusamus fugiat id iusto autem obcaecati repellat fugit cupiditate suscipit natus quas doloribus? Temporibus necessitatibus, libero.</p>
  63. <p>Architecto quisquam ipsa fugit facere, repudiandae asperiores vitae obcaecati possimus, labore excepturi reprehenderit consectetur perferendis, ullam quidem hic, repellat fugiat eaque fuga. Consectetur in eveniet, deleniti recusandae omnis eum quas?</p>
  64. <p>Quos nulla consequatur quo, officia quaerat. Nulla voluptatum, assumenda quibusdam, placeat cum aut illo deleniti dolores commodi odio ipsam, recusandae est pariatur veniam repudiandae blanditiis. Voluptas unde deleniti quisquam, nobis?</p>
  65. <p>Atque qui quaerat quasi officia molestiae, molestias totam incidunt reprehenderit laboriosam facilis veritatis, non iusto! Dolore ipsam obcaecati voluptates minima maxime minus qui mollitia facere. Nostrum esse recusandae voluptatibus eligendi.</p>
  66. </Block>
  67. </Page>
  68. <script>
  69. import {Page, Navbar, Toolbar, Link, Fab, Icon, FabButtons, FabButton, Block} from 'framework7-svelte';
  70. </script>

With Backdrop

  1. <Page>
  2. <Navbar title="FAB Backdrop" />
  3. <FabBackdrop />
  4. <Fab position="right-bottom">
  5. <Icon ios="f7:plus" aurora="f7:plus" md="material:add"></Icon>
  6. <Icon ios="f7:xmark" aurora="f7:xmark" md="material:close"></Icon>
  7. <FabButtons position="top">
  8. <FabButton label="Action 1">1</FabButton>
  9. <FabButton label="Action 2">2</FabButton>
  10. </FabButtons>
  11. </Fab>
  12. <Block>
  13. <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quia, quo rem beatae, delectus eligendi est saepe molestias perferendis suscipit, commodi labore ipsa non quasi eum magnam neque ducimus! Quasi, numquam.</p>
  14. <p>Maiores culpa, itaque! Eaque natus ab cum ipsam numquam blanditiis a, quia, molestiae aut laudantium recusandae ipsa. Ad iste ex asperiores ipsa, mollitia perferendis consectetur quam eaque, voluptate laboriosam unde.</p>
  15. <p>Sed odit quis aperiam temporibus vitae necessitatibus, laboriosam, exercitationem dolores odio sapiente provident. Accusantium id, itaque aliquam libero ipsum eos fugiat distinctio laboriosam exercitationem sequi facere quas quidem magnam reprehenderit.</p>
  16. <p>Pariatur corporis illo, amet doloremque. Ab veritatis sunt nisi consectetur error modi, nam illo et nostrum quia aliquam ipsam vitae facere voluptates atque similique odit mollitia, rerum placeat nobis est.</p>
  17. <p>Et impedit soluta minus a autem adipisci cupiditate eius dignissimos nihil officia dolore voluptatibus aperiam reprehenderit esse facilis labore qui, officiis consectetur. Ipsa obcaecati aspernatur odio assumenda veniam, ipsum alias.</p>
  18. </Block>
  19. <Block>
  20. <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Culpa ipsa debitis sed nihil eaque dolore cum iste quibusdam, accusamus doloribus, tempora quia quos voluptatibus corporis officia at quas dolorem earum!</p>
  21. <p>Quod soluta eos inventore magnam suscipit enim at hic in maiores temporibus pariatur tempora minima blanditiis vero autem est perspiciatis totam dolorum, itaque repellat? Nobis necessitatibus aut odit aliquam adipisci.</p>
  22. <p>Tenetur delectus perspiciatis ex numquam, unde corrupti velit! Quam aperiam, animi fuga veritatis consectetur, voluptatibus atque consequuntur dignissimos itaque, sint impedit cum cumque at. Adipisci sint, iusto blanditiis ullam? Vel?</p>
  23. <p>Dignissimos velit officia quibusdam! Eveniet beatae, aut, omnis temporibus consequatur expedita eaque aliquid quos accusamus fugiat id iusto autem obcaecati repellat fugit cupiditate suscipit natus quas doloribus? Temporibus necessitatibus, libero.</p>
  24. <p>Architecto quisquam ipsa fugit facere, repudiandae asperiores vitae obcaecati possimus, labore excepturi reprehenderit consectetur perferendis, ullam quidem hic, repellat fugiat eaque fuga. Consectetur in eveniet, deleniti recusandae omnis eum quas?</p>
  25. <p>Quos nulla consequatur quo, officia quaerat. Nulla voluptatum, assumenda quibusdam, placeat cum aut illo deleniti dolores commodi odio ipsam, recusandae est pariatur veniam repudiandae blanditiis. Voluptas unde deleniti quisquam, nobis?</p>
  26. <p>Atque qui quaerat quasi officia molestiae, molestias totam incidunt reprehenderit laboriosam facilis veritatis, non iusto! Dolore ipsam obcaecati voluptates minima maxime minus qui mollitia facere. Nostrum esse recusandae voluptatibus eligendi.</p>
  27. </Block>
  28. </Page>
  29. <script>
  30. import {Page, Navbar, Toolbar, Link, Fab, Icon, FabBackdrop, FabButtons, FabButton, Block} from 'framework7-svelte';
  31. </script>

← Contacts List

Gauge →