Skip to main content

ion-fab-button

Floating Action Buttons (FABs) represent the primary action in an application. By default, they have a circular shape. When pressed, the button may open more related actions. As the name suggests, FABs generally float over the content in a fixed position. This is not achieved exclusively by using an <ion-fab-button>FAB</ion-fab-button>. They need to be wrapped with an <ion-fab> component in order to be fixed over the content.

If the FAB button is not wrapped with <ion-fab>, it will scroll with the content. FAB buttons have a default size, a mini size and can accept different colors:

Usage#

<ion-content>
<!-- Fixed Floating Action Button that does not scroll with the content -->
<ion-fab slot="fixed">
<ion-fab-button>Button</ion-fab-button>
</ion-fab>
<!-- Default Floating Action Button that scrolls with the content.-->
<ion-fab-button>Default</ion-fab-button>
<!-- Mini -->
<ion-fab-button size="small">Mini</ion-fab-button>
<!-- Colors -->
<ion-fab-button color="primary">Primary</ion-fab-button>
<ion-fab-button color="secondary">Secondary</ion-fab-button>
<ion-fab-button color="danger">Danger</ion-fab-button>
<ion-fab-button color="light">Light</ion-fab-button>
<ion-fab-button color="dark">Dark</ion-fab-button>
</ion-content>

Properties#

activated#

DescriptionIf true, the fab button will be show a close icon.
Attributeactivated
Typeboolean
Defaultfalse

closeIcon#

DescriptionThe icon name to use for the close icon. This will appear when the fab button
is pressed. Only applies if it is the main button inside of a fab containing a
fab list.
Attributeclose-icon
Typestring
Default'close'

color#

DescriptionThe color to use from your application's color palette.
Default options are: "primary", "secondary", "tertiary", "success", "warning", "danger", "light", "medium", and "dark".
For more information on colors, see theming.
Attributecolor
Typestring \| undefined
Defaultundefined

disabled#

DescriptionIf true, the user cannot interact with the fab button.
Attributedisabled
Typeboolean
Defaultfalse

download#

DescriptionThis attribute instructs browsers to download a URL instead of navigating to
it, so the user will be prompted to save it as a local file. If the attribute
has a value, it is used as the pre-filled file name in the Save prompt
(the user can still change the file name if they want).
Attributedownload
Typestring \| undefined
Defaultundefined

href#

DescriptionContains a URL or a URL fragment that the hyperlink points to.
If this property is set, an anchor tag will be rendered.
Attributehref
Typestring \| undefined
Defaultundefined

mode#

DescriptionThe mode determines which platform styles to use.
Attributemode
Type"ios" \| "md"
Defaultundefined

rel#

DescriptionSpecifies the relationship of the target object to the link object.
The value is a space-separated list of link types.
Attributerel
Typestring \| undefined
Defaultundefined

routerAnimation#

DescriptionWhen using a router, it specifies the transition animation when navigating to
another page using href.
Attributeundefined
Type((baseEl: any, opts?: any) => Animation) \| undefined
Defaultundefined

routerDirection#

DescriptionWhen using a router, it specifies the transition direction when navigating to
another page using href.
Attributerouter-direction
Type"back" \| "forward" \| "root"
Default'forward'

show#

DescriptionIf true, the fab button will show when in a fab-list.
Attributeshow
Typeboolean
Defaultfalse

size#

DescriptionThe size of the button. Set this to small in order to have a mini fab button.
Attributesize
Type"small" \| undefined
Defaultundefined

target#

DescriptionSpecifies where to display the linked URL.
Only applies when an href is provided.
Special keywords: "_blank", "_self", "_parent", "_top".
Attributetarget
Typestring \| undefined
Defaultundefined

translucent#

DescriptionIf true, the fab button will be translucent.
Only applies when the mode is "ios" and the device supports
backdrop-filter.
Attributetranslucent
Typeboolean
Defaultfalse

type#

DescriptionThe type of the button.
Attributetype
Type"button" \| "reset" \| "submit"
Default'button'

Events#

NameDescription
ionBlurEmitted when the button loses focus.
ionFocusEmitted when the button has focus.

CSS Shadow Parts#

NameDescription
close-iconThe close icon that is displayed when a fab list opens (uses ion-icon).
nativeThe native HTML button or anchor element that wraps all child elements.

CSS Custom Properties#

NameDescription
--backgroundBackground of the button
--background-activatedBackground of the button when pressed. Note: setting this will interfere with the Material Design ripple.
--background-activated-opacityOpacity of the button background when pressed
--background-focusedBackground of the button when focused with the tab key
--background-focused-opacityOpacity of the button background when focused with the tab key
--background-hoverBackground of the button on hover
--background-hover-opacityOpacity of the button background on hover
--border-colorBorder color of the button
--border-radiusBorder radius of the button
--border-styleBorder style of the button
--border-widthBorder width of the button
--box-shadowBox shadow of the button
--close-icon-font-sizeFont size of the close icon
--colorText color of the button
--color-activatedText color of the button when pressed
--color-focusedText color of the button when focused with the tab key
--color-hoverText color of the button on hover
--padding-bottomBottom padding of the button
--padding-endRight padding if direction is left-to-right, and left padding if direction is right-to-left of the button
--padding-startLeft padding if direction is left-to-right, and right padding if direction is right-to-left of the button
--padding-topTop padding of the button
--ripple-colorColor of the button ripple effect
--transitionTransition of the button