Back

addFloatingActionButton

JS Py
Hello World
Content:
- Examples ##
- Properties
- Methods

A Floating Action Button (FAB) is a prominent, circular button that hovers above the content, typically used for a primary action in an application.

fab = ui.addFloatingActionButton( parent, icon, options, text ) → ui object: FloatingActionButton

If you want the fab to position relative to the layout and not on the bottom right corner, pass a Static option. If fab is Extended pass a text argument.

Here are the available methods for the Floating Action Button.

Examples ##

#Example - Basic FABclass Main extends App{onStart(){// Create a fullscreen linear layout with objects vertically centeredthis.main = ui.addLayout("main", "Linear", "VCenter,FillXY")// Add a floating action button to the main layout.// By default, FAB is positioned fix at the bottom right cornerthis.fab = ui.addFAB(this.main, "add")// Add a callback handler for onTouch event on the FABthis.fab.setOnTouch( this.onTouch )}onTouch(){ui.showPopup( "You click me!" )}}

Example - Primary static FAB

class Main extends App
{
    onStart()
    {
        // Create a fullscreen linear layout with objects vertically centered
        this.main = ui.addLayout("main", "Linear", "VCenter,FillXY")

        // Add a primary floating action button to the main layout.
        // Passing `Static` will ignore fixed positioning
        // and will follow the flow of the parent layout
        this.fab = ui.addFAB( this.main, "add", "Primary,Static" )

        // Add a callback handler for `onTouch` event on the FAB
        this.fab.setOnTouch( this.onTouch )
    }

    onTouch()
    {
        ui.showPopup( "You click me!" )
    }
}
class Main extends App
    onStart()
        # Create a fullscreen linear layout with objects vertically centered
        this.main = ui.addLayout("main", "Linear", "VCenter,FillXY")

        # Add a primary floating action button to the main layout.
        # Passing `Static` will ignore fixed positioning
        # and will follow the flow of the parent layout
        this.fab = ui.addFAB( this.main, "add", "Primary,Static" )

        # Add a callback handler for `onTouch` event on the FAB
        this.fab.setOnTouch( this.onTouch )

    onTouch()
        ui.showPopup( "You click me!" )
Copy All       Run      

Example - Extended FAB

class Main extends App
{
    onStart()
    {
        // Create a fullscreen linear layout with objects vertically centered
        this.main = ui.addLayout("main", "Linear", "VCenter,FillXY")

        // Add a secondary floating action button to the main layout.
        // Passing `Extended` enables to add more text on the FAB
        this.fab = ui.addFAB(this.main, "add", "Secondary,Extended", "New message")

        // Add a callback handler for `onTouch` event on the FAB
        this.fab.setOnTouch( this.onTouch )
    }

    onTouch()
    {
        ui.showPopup( "You click me!" )
    }
}
class Main extends App
    onStart()
        # Create a fullscreen linear layout with objects vertically centered
        this.main = ui.addLayout("main", "Linear", "VCenter,FillXY")

        # Add a secondary floating action button to the main layout.
        # Passing `Extended` enables to add more text on the FAB
        this.fab = ui.addFAB(this.main, "add", "Secondary,Extended", "New message")

        # Add a callback handler for `onTouch` event on the FAB
        this.fab.setOnTouch( this.onTouch )

    onTouch()
        ui.showPopup( "You click me!" )
Copy All       Run      

Example - Secondary,Extended,Left

class Main extends App
{
    onStart()
    {
        // Create a fullscreen linear layout with objects vertically centered
        this.main = ui.addLayout("main", "Linear", "VCenter,FillXY")

        // Add a secondary floating action button to the main layout.
        // Passing `Left` option will position the FAB on the bottom left corner
        this.fab = ui.addFAB(this.main, "add", "Secondary,Extended,Left", "New message")

        // Add a callback handler for `onTouch` event on the FAB
        this.fab.setOnTouch( this.onTouch )
    }

    onTouch()
    {
        ui.showPopup( "You click me!" )
    }
}
class Main extends App
    onStart()
        # Create a fullscreen linear layout with objects vertically centered
        this.main = ui.addLayout("main", "Linear", "VCenter,FillXY")

        # Add a secondary floating action button to the main layout.
        # Passing `Left` option will position the FAB on the bottom left corner
        this.fab = ui.addFAB(this.main, "add", "Secondary,Extended,Left", "New message")

        # Add a callback handler for `onTouch` event on the FAB
        this.fab.setOnTouch( this.onTouch )

    onTouch()
        ui.showPopup( "You click me!" )
Copy All       Run      

Properties

The following properties are available on the FloatingActionButton object:

absHeightNumber
absLeftNumber
absTopNumber
absWidthNumber
backColorString
backImageString
borderNumber
borderColorString
borderStyleString
colorString
cornerRadiusNumber
disabledBoolean
disabledRippleBoolean
elObject
elStyleString
fontFileString
heightNumber
iconString
iconSizeNumber
isVisibleBoolean
leftNumber
marginsList
opacityNumber
optionsString
paddingList
parentObject
positionObject
rotationNumber
sizeVariantString
textString
textColorString
textSizeNumber
topNumber
typeString
variantString
visibilityString
widthNumber

Methods

The following methods are available on the FloatingActionButton object:

getPosition( options ) → Object
gone()
hide()
setScale( x, y )
show()
Number: The time in milliseconds.
Number: The z-index. A negative value behaves like `sendBackward` method.
Number: The z-index. A positve value behaves like `bringForward` method.
Number: Border-left thickness in pixels.
Number: Border-top thickness in pixels.
Number: Border-right thickness in pixels.
Number: Border-bottom thickness in pixels.
Number: Top-left corner radius.
Number: Top-right corner radius.
Number: Bottom-left corner radius.
Number: Bottom-right corner radius.
Number: Left margin. You can also pass string e.g. `12rem`
Number: Top margin. You can also pass string e.g. `12rem`
Number: Right margin. You can also pass string e.g. `12rem`
Number: Bottom margin. You can also pass string e.g. `12rem`
Number: Fraction of the component width.
Number: Fraction of the component height. [0-1]
Number: Fraction of the component width. [0-1]
Number: Fraction of the parent width. [0-1]
Number: Fraction of the parent height. [0-1]
Number: The x-scale of the component.Values less than `0` is smaller than the normal. While values greater than `1` is greater than the normal.
Number: The y-scale of the component. Values less than `1` is smaller than the normal. While vaues greater than `1` is greater than the normal.
String: “The string icon of the FAB”
String: “A comma separated option.
Position: `Fixed`”
, “ `Static`
Style: `Rounded`”
, “ `Extended`
Anchor: `Left`”
, “ `Right`”
String: “Text to show for extended FABs”
String: “The type of animation. Here are the available values
`bounce`”
, “ `flash`”, “ `pulse`”, “ `rubberBand`”, “ `shakeX`”, “ `shakeY`”, “ `headShake`”, “ `swing`”, “ `tada`”, “ `wobble`”, “ `jello`”, “ `heartBeat`”,
Back Entrances: `backInDown`”
, “ `backInLeft`”, “ `backInRight`”, “ `backInUp`
Back Exits: `backOutDown`”
, “ `backOutLeft`”, “ `backOutRight`”, “ `backOutUp`
Bouncing Entrances: `bounceIn`”
, “ `bounceInDown`”, “ `bounceInLeft`”, “ `bounceInRight`”, “ `bounceInUp`
Bouncing exits: `bounceOut`”
, “ `bounceOutDown`”, “ `bounceOutLeft`”, “ `bounceOutRight`”, “ `bounceOutUp`
Fading entrances: `fadeIn`”
, “ `fadeInDown`”, “ `fadeInDownBig`”, “ `fadeInLeft`”, “ `fadeInLeftBig`”, “ `fadeInRight`”, “ `fadeInRightBig`”, “ `fadeInUp`”, “ `fadeInUpBig`”, “ `fadeInTopLeft`”, “ `fadeInTopRight`”, “ `fadeInBottomLeft`”, “ `fadeInBottomRight`
Fading exits: `fadeOut`”
, “ `fadeOutDown`”, “ `fadeOutDownBig`”, “ `fadeOutLeft`”, “ `fadeOutLeftBig`”, “ `fadeOutRight`”, “ `fadeOutRightBig`”, “ `fadeOutUp`”, “ `fadeOutUpBig`”, “ `fadeOutTopLeft`”, “ `fadeOutTopRight`”, “ `fadeOutBottomRight`”, “ `fadeOutBottomLeft`
Flippers: `flip`”
, “ `flipInX`”, “ `flipInY`”, “ `flipOutX`”, “ `flipOutY`
Lightspeed: `lightSpeedInRight`”
, “ `lightSpeedInLeft`”, “ `lightSpeedOutRight`”, “ `lightSpeedOutLeft`
Rotating Entrances: `rotateIn`”
, “ `rotateInDownLeft`”, “ `rotateInDownRight`”, “ `rotateInUpLeft`”, “ `rotateInUpRight`
Rotating Exits: `rotateOut`”
, “ `rotateOutDownLeft`”, “ `rotateOutDownRight`”, “ `rotateOutUpLeft`”, “ `rotateOutUpRight`
Specials: `hinge`”
, “ `jackInTheBox`”, “ `rollIn`”, “ `rollOut`
Zooming Entrances: `zoomIn`”
, “ `zoomInDown`”, “ `zoomInLeft`”, “ `zoomInRight`”, “ `zoomInUp`
Zooming Exits: `zoomOut`”
, “ `zoomOutDown`”, “ `zoomOutLeft`”, “ `zoomOutRight`”, “ `zoomOutUp`
Sliding Entrances: `slideInDown`”
, “ `slideInLeft`”, “ `slideInRight`”, “ `slideInUp`
Sliding Exits: `slideOutDown`”
, “ `slideOutLeft`”, “ `slideOutRight`”, “ `slideOutUp`”
String: “The mode of the measurements. Values can be `px` or `%`”
String: “Border color in hexadecimal format `#rrggbb`.”
String: “Border-styles. Values can be `dotted`”, “ `dashed`”, “ `solid`”, “ `double`”, “ `groove`”, “ `ridge`”, “ `inset` and `outset`. Default is `solid`”
String: “Unit. Values are `px` `rem` or `%`.”
String: “Unit of measurement.
`rem` for root em.
`px` for pixels
`%` relative to its parent dimension.
`v` relative to viewport dimension.”
String: “Unit of measurement.
`rem` for root em.
`px` for pixels
`%` relative to its parent dimensions
`v` relative to viewport dimensions.”
String: “Unit of measurment. Can be "px"”, “ "rem"”, “ "%"”, “ "v" for viewport width/height or any css supported unit.”
Object: The parent layout where to add the fab
Object: The pointer event object.
Object: The position of the touch event.
function( event )
function( pos )
fab.absHeight
Returns the absolute height of the control in pixels.
fab.absLeft
Returns the absolute distance of the control from the left in pixels.
fab.absTop
Returns the absolute distance of the control from the top in pixels.
fab.absWidth
Returns the absolute width of the control in pixels.
fab.animate
Animate the component.
fab.backColor
A hexadecimal color of the form #rrggbb
fab.backImage
The path to your image file.
fab.border
Sets or returns the border thickness in pixels.
fab.borderColor
Sets or returns the border color. Color is in hexadecimal form #rrggbb
fab.borderStyle
Sets or returns the border style. Values can be dotted, dashed, solid, double, groove, ridge, inset and outset. Default is solid.
fab.bringForward
Bring this component forward by a given z-index.
fab.color
Sets or returns the theme color for the FAB. Values can be Default Primary or Secondary
fab.cornerRadius
Sets or returns the corner radius in pixels.
fab.destroy
Destroy the component.
fab.disabled
Sets or returns the disabled state of the control.
fab.disabledRipple
Sets or returns the disabled state of the ripple effect.
fab.el
Returns the html container element for the control.
fab.elStyle
Sets the style of the html container element.
fab.fontFile
Sets or returns the relative path to the font-family use.
fab.getPosition
Returns the position of the component. The return object is of the form {left, top, right, bottom}
fab.gone
Destroy the component.
fab.height
Sets or returns the height of the control as a fraction of the parent control.
fab.hide
Hide the component.
fab.icon
Sets or returns the material icon font.
fab.iconSize
Sets or returns the size of the icon.
fab.isVisible
Returns whether the control is visible or not.
fab.left
Returns the distance of the control from the left.
fab.margins
Sets or returns the margin of the control. Works on controls with Linear parent only. You can also pass a number to set equal margins for all sides.
fab.opacity
Sets or returns the opacity of the control.
fab.options
Sets or returns the options of the control.
fab.padding
Sets or returns the padding of the control. You can also pass a number to set equal padding for all sides.
fab.parent
Returns the parent layout control.
fab.position
Returns the position of the control. The returned object has left top right and bottom props.
fab.rotation
Sets or returns the angle of rotation in degrees.
fab.sendBackward
Bring this component backward by a given z-index.
fab.setBorder
Sets the border line for the component container.
fab.setCornerRadius
Sets the corner radius of the button.
fab.setMargins
Sets the margin of the component.
fab.setOnContextMenu
Adds a callback function on right click.
fab.setOnTouch
Adds a callback handler when the FAB is touch.
fab.setPadding
Sets the padding of the component's container.
fab.setPosition
Sets the position of the component relative to its parent dimensions.
fab.setScale
Sets the x and y scaling of the component. This will ignore the positioning and flow of controls in the layout.
fab.setSize
Sets the size of the component.
fab.show
Show the component.
fab.sizeVariant
Sets or returns the size variant of the FAB. Values can be Small Medium or Large
fab.text
Sets or returns the text for extended FAB.
fab.textColor
Sets or returns the color of the text.
fab.textSize
Sets or returns the size of the text within the control.
fab.top
Returns the distance of the control from the top.
fab.type
Returns the type of the control.
fab.variant
Sets or returns the variant use for the FAB. Can be Extended or Rounded
fab.visibility
Sets or returns the visibility of the control.
fab.width
Sets or returns the width of the control as a fraction of the parent control.