Skip to main content

fab

pb.fab()

Set up a floating action button (FAB) on the page.

To set it up, create an instance with fab(), then call its init function by passing in the desired main button and an array of additional buttons.

Fab

The fab object provides functions for updating the floating action button and its status. This object is only available on pages where a FAB would exist.

Methods

init

fabInstance.init(options)

Initializes the FAB

Returns: Object - Returns the FAB object.

ParamTypeDescription
optionsObject
options.mainFabButtonProperties of the primary button to display when the FAB is visible.
options.buttonsArray.<FabButton>An array containing the secondary buttons to display when hovering over the FAB.

open

fabInstance.open()

Opens the FAB

Returns: Object - Returns the FAB object.

close

fabInstance.close()

Closes the FAB

Returns: Object - Returns the FAB object.

isOpen

fabInstance.isOpen()

Check if the FAB is currently open.

Returns: boolean - Current open status

addButton

fabInstance.addButton(options)

Adds a button to the top of the FAB.

ParamTypeDescription
optionsFabButtonProperties of the newly added button.

removeButton

fabInstance.removeButton(options)

Remove a button from the FAB by its class name

ParamTypeDescription
optionsObject
options.classNamestringThe class of the button

modifyButton

fabInstance.modifyButton(options)

Modify a button from the FAB by its class name

ParamTypeDescription
optionsObject
options.classNamestringThe class of the button
options.classesToRemovestringThe classes you want to remove from the button
options.classesToAddstringThe classes you want to add to the button
options.newDescriptionTextstringThe new description text to set
options.newActionfunctionThe new action for the button

hasButton

fabInstance.hasButton(options)

Checks to see if a button exists in the fab

Returns: boolean - Returns true or false.

ParamTypeDescription
optionsObject
options.classNamestringThe class of the button

isHidden

fabInstance.isHidden()

Checks to see if a button exists in the fab

Returns: boolean - Returns true or false.

FabButton

A FabButton is the main button or a secondary button that appears when hovering over the FAB.

Properties

NameTypeDescription
options.classNameStringClass to apply to the button, should be unique
options.iconStringThe icon to apply to the button
[options.text]StringThe description of the button
[options.action]functionThe function to execute when pressing the button, will ignore href if present
[options.href]StringThe destination upon clicking, will only work if there is no action