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.
There are following components included:
Fab
- main FAB elementName | Type | Default | Description |
---|---|---|---|
colors | object | Object with Tailwind CSS colors classes | |
colors.activeBgIos | string | 'active:bg-ios-primary-shade' | |
colors.activeBgMaterial | string | '' | |
colors.bgIos | string | 'bg-primary' | |
colors.bgMaterial | string | 'bg-md-light-primary-container dark:bg-md-dark-primary-container' | |
colors.textIos | string | 'text-white' | |
colors.textMaterial | string | 'text-md-light-on-primary-container dark:text-md-dark-on-primary-container' | |
colors.touchRipple | string | 'touch-ripple-primary dark:touch-ripple-white' | |
component | string | 'a' | Component's HTML Element |
href | string | Fab's link | |
icon | ReactNode | Fab's icon | |
text | ReactNode | Button text (content) | |
textPosition | 'after' | 'before' | 'after' | Text position, can be |
touchRipple | boolean | true | Enables touch ripple effect in Material theme |
import React from 'react';import {Page,Navbar,NavbarBackLink,Block,Fab,useTheme,} from 'konsta/react';import { Plus } from 'framework7-icons/react';import { MdAdd } from 'react-icons/md';export default function FabPage() {const theme = useTheme();const PlusIcon = theme === 'ios' ? Plus : MdAdd;return (<Page><Navbartitle="FAB"/>{/* Right Top */}<FabclassName="fixed right-4-safe ios:top-15-safe material:top-18-safe z-20 k-color-brand-red"icon={<PlusIcon />}/>{/* Right Bottom */}<FabclassName="fixed right-4-safe bottom-4-safe z-20"icon={<PlusIcon />}/>{/* Left Bottom */}<FabclassName="fixed left-4-safe bottom-4-safe z-20 k-color-brand-green"icon={<PlusIcon />}/>{/* Left Top */}<FabclassName="fixed left-4-safe ios:top-15-safe material:top-18-safe z-20 k-color-brand-yellow"icon={<PlusIcon />}/>{/* Center Center */}<FabclassName="fixed left-1/2 top-1/2 transform -translate-x-1/2 -translate-y-1/2 z-20"icon={<PlusIcon />}/>{/* Center Bottom */}<FabclassName="fixed left-1/2 bottom-4-safe transform -translate-x-1/2 z-20"icon={<PlusIcon />}text="Create"textPosition="after"/><Block className="space-y-4"><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quia, quorem beatae, delectus eligendi est saepe molestias perferendissuscipit, commodi labore ipsa non quasi eum magnam neque ducimus!Quasi, numquam.</p><p>Maiores culpa, itaque! Eaque natus ab cum ipsam numquam blanditiis a,quia, molestiae aut laudantium recusandae ipsa. Ad iste ex asperioresipsa, mollitia perferendis consectetur quam eaque, voluptatelaboriosam unde.</p><p>Sed odit quis aperiam temporibus vitae necessitatibus, laboriosam,exercitationem dolores odio sapiente provident. Accusantium id, itaquealiquam libero ipsum eos fugiat distinctio laboriosam exercitationemsequi facere quas quidem magnam reprehenderit.</p><p>Pariatur corporis illo, amet doloremque. Ab veritatis sunt nisiconsectetur error modi, nam illo et nostrum quia aliquam ipsam vitaefacere voluptates atque similique odit mollitia, rerum placeat nobisest.</p><p>Et impedit soluta minus a autem adipisci cupiditate eius dignissimosnihil officia dolore voluptatibus aperiam reprehenderit esse facilislabore qui, officiis consectetur. Ipsa obcaecati aspernatur odioassumenda veniam, ipsum alias.</p></Block><Block className="space-y-4"><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Culpa ipsadebitis sed nihil eaque dolore cum iste quibusdam, accusamusdoloribus, tempora quia quos voluptatibus corporis officia at quasdolorem earum!</p><p>Quod soluta eos inventore magnam suscipit enim at hic in maiorestemporibus pariatur tempora minima blanditiis vero autem estperspiciatis totam dolorum, itaque repellat? Nobis necessitatibus autodit aliquam adipisci.</p><p>Tenetur delectus perspiciatis ex numquam, unde corrupti velit! Quamaperiam, animi fuga veritatis consectetur, voluptatibus atqueconsequuntur dignissimos itaque, sint impedit cum cumque at. Adipiscisint, iusto blanditiis ullam? Vel?</p><p>Dignissimos velit officia quibusdam! Eveniet beatae, aut, omnistemporibus consequatur expedita eaque aliquid quos accusamus fugiat idiusto autem obcaecati repellat fugit cupiditate suscipit natus quasdoloribus? Temporibus necessitatibus, libero.</p><p>Architecto quisquam ipsa fugit facere, repudiandae asperiores vitaeobcaecati possimus, labore excepturi reprehenderit consecteturperferendis, ullam quidem hic, repellat fugiat eaque fuga. Consecteturin eveniet, deleniti recusandae omnis eum quas?</p><p>Quos nulla consequatur quo, officia quaerat. Nulla voluptatum,assumenda quibusdam, placeat cum aut illo deleniti dolores commodiodio ipsam, recusandae est pariatur veniam repudiandae blanditiis.Voluptas unde deleniti quisquam, nobis?</p><p>Atque qui quaerat quasi officia molestiae, molestias totam inciduntreprehenderit laboriosam facilis veritatis, non iusto! Dolore ipsamobcaecati voluptates minima maxime minus qui mollitia facere. Nostrumesse recusandae voluptatibus eligendi.</p></Block></Page>);}FabPage.title = 'FAB (Floating Action Button)';