Skip to content

Fab

A Floating Action Button (FAB) is a special circular button that represents the primary action in an application. It is typically fixed on the screen with elevation shadows and hover animations, similar to the FAB component in Material Design.

Basic Usage

Basic floating action button with different color themes.

vue
<template>
  <u-fab>+</u-fab>
  <u-fab color="success">+</u-fab>
  <u-fab color="warning">+</u-fab>
  <u-fab color="error">+</u-fab>
  <u-fab color="info">+</u-fab>
</template>

Different Sizes

Floating action buttons come in four different sizes: small, medium, large, and the extended variant.

vue
<template>
  <u-fab size="small">+</u-fab>
  <u-fab size="medium">+</u-fab>
  <u-fab size="large">+</u-fab>
</template>

Extended FAB

Extended FAB supports displaying text, with optional icons.

vue
<template>
  <u-fab size="extended" color="primary">
    <template #icon>+</template>
    Create
  </u-fab>
  
  <u-fab size="extended" color="success" label="Save"></u-fab>
  
  <u-fab size="extended" color="error">
    <template #icon>🗑</template>
    Delete
  </u-fab>
</template>

Button States

FAB supports disabled, loading, and no-shadow states.

vue
<template>
  <u-fab disabled color="primary">×</u-fab>
  <u-fab loading color="primary"></u-fab>
  <u-fab :shadow="false" color="primary">+</u-fab>
</template>

Fixed Positioning

Using the fixed prop along with top, right, bottom, left props, you can fix the floating button at any position on the screen.

TIP

Scroll the page to observe the button remains in a fixed position

vue
<template>
  <u-fab 
    color="primary" 
    fixed 
    bottom="24px" 
    right="24px"
    @click="handleAction"
  >
    +
  </u-fab>

  <u-fab 
    color="error" 
    size="small"
    fixed 
    bottom="100px" 
    right="24px"
  >

  </u-fab>
</template>

Props

PropDescriptionTypeDefaultAccepted Values
colorButton color themestringprimaryprimary / success / warning / error / info
sizeButton sizestringmediumsmall / medium / large / extended
disabledWhether the button is disabledbooleanfalse-
loadingWhether to show loading statebooleanfalse-
fixedWhether to use fixed positioningbooleanfalse-
topTop value when fixed positionedstring-e.g., 24px
rightRight value when fixed positionedstring-e.g., 24px
bottomBottom value when fixed positionedstring-e.g., 24px
leftLeft value when fixed positionedstring-e.g., 24px
shadowWhether to show shadowbooleantrue-
labelButton text in extended modestring--
widthButton widthstring--
heightButton heightstring--

Methods

MethodDescriptionParameters
focusFocus the button-
blurBlur the button-

Slots

Slot NameDescription
defaultButton content or text label in extended mode
iconCustom icon