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
- Angular
- Javascript
- React
- Stencil
- Vue
<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>
<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>
import React from 'react';
import { IonContent, IonFab, IonFabButton } from '@ionic/react';
export const FabButtonExample: React.FC = () => (
<IonContent>
{/*-- Fixed Floating Action Button that does not scroll with the content --*/}
<IonFab slot="fixed">
<IonFabButton>Button</IonFabButton>
</IonFab>
{/*-- Default Floating Action Button that scrolls with the content.--*/}
<IonFabButton>Default</IonFabButton>
{/*-- Mini --*/}
<IonFabButton size="small">Mini</IonFabButton>
{/*-- Colors --*/}
<IonFabButton color="primary">Primary</IonFabButton>
<IonFabButton color="secondary">Secondary</IonFabButton>
<IonFabButton color="danger">Danger</IonFabButton>
<IonFabButton color="light">Light</IonFabButton>
<IonFabButton color="dark">Dark</IonFabButton>
</IonContent>
);
import { Component, h } from '@stencil/core';
@Component({
tag: 'fab-button-example',
styleUrl: 'fab-button-example.css',
})
export class FabButtonExample {
render() {
return [
<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>,
];
}
}