Floating action buttons (FAB)

FAB is a button for the main action of a screen. It floats above the content so the action is always in reach.

Extended FABs add a text label to a FAB, which makes them wider and easier to hit.

The 3 sizes of FAB

View interactive demo inline.

Open interactive demo in new tab.

accessible_forward
1
edit
2
palette
3
  1. FAB
  2. Small FAB
  3. Large FAB
navigation
1
2

FABs should have an icon, such as a font petal-icon, an svg, or an img.

edit
<petal-fab aria-label="Edit">
  <petal-icon slot="icon">edit</petal-icon>
</petal-fab>

FABs can be set to a lower elevation with the lowered attribute.

edit
<petal-fab lowered aria-label="Edit">
  <petal-icon slot="icon">edit</petal-icon>
</petal-fab>

Icon-only FABs must include an aria-label that describes its action. Otherwise if aria-label is not provided, the FAB will default to announcing its visible contents.

<petal-fab aria-label="Edit">
  <petal-icon slot="icon">edit</petal-icon>
</petal-fab>

Extended FABs use their label for accessibility. Add an aria-label for additional context if needed. By supplying the label attribute, the extended FAB will make sure that the icon is not announced.

<petal-fab label="Edit" aria-label="Edit Comment">
  <petal-icon slot="icon">edit</petal-icon>
</petal-fab>

FABs should display a clear and understandable icon.

edit
<petal-fab aria-label="Edit">
  <petal-icon slot="icon">edit</petal-icon>
</petal-fab>

FABs may be extended with a label for additional emphasis. Extended FABs can omit their icon.

edit
<petal-fab label="Edit">
  <petal-icon slot="icon">edit</petal-icon>
</petal-fab>

Extended FABs are the only FABs that can be used without an icon.

<petal-fab label="Reroute"></petal-fab>

FAB colors may be changed with the variant attribute. It can be set to "surface" (default), "primary", "secondary", or "tertiary". These use the container colors (for example primary-container). For the solid colors, use "filled-primary", "filled-secondary", or "filled-tertiary" (see Material 3 Expressive features).

editeditedit
<petal-fab variant="primary" aria-label="Edit">
  <petal-icon slot="icon">edit</petal-icon>
</petal-fab>
<petal-fab variant="secondary" aria-label="Edit">
  <petal-icon slot="icon">edit</petal-icon>
</petal-fab>
<petal-fab variant="tertiary" aria-label="Edit">
  <petal-icon slot="icon">edit</petal-icon>
</petal-fab>

FABs may be small, medium (default), or large by setting the size attribute. Small FABs can optionally further reduce their touch target.

editediteditedit
<petal-fab size="small" touch-target="none" aria-label="Edit">
  <petal-icon slot="icon">edit</petal-icon>
</petal-fab>
<petal-fab size="small" aria-label="Edit">
  <petal-icon slot="icon">edit</petal-icon>
</petal-fab>
<petal-fab aria-label="Edit">
  <petal-icon slot="icon">edit</petal-icon>
</petal-fab>
<petal-fab size="large" aria-label="Edit">
  <petal-icon slot="icon">edit</petal-icon>
</petal-fab>

Branded FABs use a brightly colored logo for their icon. Unlike FAB, branded FABs do not have color variants.

<petal-branded-fab size="small" aria-label="Add">
  <svg slot="icon" viewBox="0 0 36 36">
    <ellipse cx="18" cy="10" rx="5" ry="8" fill="#F48FB1"></ellipse>
    <ellipse cx="26" cy="18" rx="8" ry="5" fill="#EC407A"></ellipse>
    <ellipse cx="18" cy="26" rx="5" ry="8" fill="#F06292"></ellipse>
    <ellipse cx="10" cy="18" rx="8" ry="5" fill="#F8BBD0"></ellipse>
    <circle cx="18" cy="18" r="4" fill="#FFD54F"></circle>
  </svg>
</petal-branded-fab>

Branded FABs may be extended with a label for additional emphasis. Unlike FAB, branded FABs should always display their logo icon.

<petal-branded-fab label="Add">
  <svg slot="icon" viewBox="0 0 36 36">
    <ellipse cx="18" cy="10" rx="5" ry="8" fill="#F48FB1"></ellipse>
    <ellipse cx="26" cy="18" rx="8" ry="5" fill="#EC407A"></ellipse>
    <ellipse cx="18" cy="26" rx="5" ry="8" fill="#F06292"></ellipse>
    <ellipse cx="10" cy="18" rx="8" ry="5" fill="#F8BBD0"></ellipse>
    <circle cx="18" cy="18" r="4" fill="#FFD54F"></circle>
  </svg>
</petal-branded-fab>

Branded FABs may be medium (default) or large by setting the size attribute.

<petal-branded-fab aria-label="Add">
  <svg slot="icon" viewBox="0 0 36 36">
    <ellipse cx="18" cy="10" rx="5" ry="8" fill="#F48FB1"></ellipse>
    <ellipse cx="26" cy="18" rx="8" ry="5" fill="#EC407A"></ellipse>
    <ellipse cx="18" cy="26" rx="5" ry="8" fill="#F06292"></ellipse>
    <ellipse cx="10" cy="18" rx="8" ry="5" fill="#F8BBD0"></ellipse>
    <circle cx="18" cy="18" r="4" fill="#FFD54F"></circle>
  </svg>
</petal-branded-fab>
<petal-branded-fab size="large" aria-label="Add">
  <svg slot="icon" viewBox="0 0 36 36">
    <ellipse cx="18" cy="10" rx="5" ry="8" fill="#F48FB1"></ellipse>
    <ellipse cx="26" cy="18" rx="8" ry="5" fill="#EC407A"></ellipse>
    <ellipse cx="18" cy="26" rx="5" ry="8" fill="#F06292"></ellipse>
    <ellipse cx="10" cy="18" rx="8" ry="5" fill="#F8BBD0"></ellipse>
    <circle cx="18" cy="18" r="4" fill="#FFD54F"></circle>
  </svg>
</petal-branded-fab>

FAB supports Material theming and can be customized in terms of color, typography, and shape.

TokenDefault value
--md-fab-container-color--md-sys-color-surface-container-high
--md-fab-lowered-container-color--md-sys-color-surface-container-low
--md-fab-container-shape--md-sys-shape-corner-large
--md-fab-icon-color--md-sys-color-primary
--md-fab-icon-size24px
edit
<style>
  :root {
    --md-sys-color-surface-container-high: #e3e9e9;
    --md-sys-color-primary: #006a6a;
    --md-fab-container-shape: 0px;
    --md-fab-icon-size: 36px;
    background-color: #f4fbfa;
  }
</style>
<petal-fab aria-label="Edit">
  <petal-icon slot="icon">edit</petal-icon>
</petal-fab>
TokenDefault value
--md-fab-small-container-shape--md-sys-shape-corner-medium
--md-fab-small-icon-size24px
--md-fab-large-container-shape--md-sys-shape-corner-extra-large
--md-fab-large-icon-size36px
TokenDefault value
--md-fab-label-text-font--md-sys-typescale-label-large-font
edit
<style>
  :root {
    --md-sys-color-surface-container-high: #e3e9e9;
    --md-sys-color-on-surface: #161d1d;
    --md-sys-color-primary: #006a6a;
    --md-fab-container-shape: 0px;
    --md-fab-icon-size: 36px;
    background-color: #f4fbfa;
  }
</style>
<petal-fab label="Edit">
  <petal-icon slot="icon">edit</petal-icon>
</petal-fab>
TokenDefault value
--md-fab-branded-container-color--md-sys-color-surface-container-high
--md-fab-branded-container-shape--md-sys-shape-corner-large
--md-fab-branded-icon-size36px
--md-fab-branded-label-text-font--md-sys-typescale-label-large-font
<style>
  :root {
    --md-sys-color-surface-container-high: #e3e9e9;
    --md-sys-color-on-surface: #161d1d;
    --md-fab-branded-icon-size: 48px;
    --md-fab-branded-container-shape: 0px;
    background-color: #f4fbfa;
  }
</style>
<petal-branded-fab size="small" aria-label="Add">
  <svg slot="icon" viewBox="0 0 36 36">
    <ellipse cx="18" cy="10" rx="5" ry="8" fill="#F48FB1"></ellipse>
    <ellipse cx="26" cy="18" rx="8" ry="5" fill="#EC407A"></ellipse>
    <ellipse cx="18" cy="26" rx="5" ry="8" fill="#F06292"></ellipse>
    <ellipse cx="10" cy="18" rx="8" ry="5" fill="#F8BBD0"></ellipse>
    <circle cx="18" cy="18" r="4" fill="#FFD54F"></circle>
  </svg>
</petal-branded-fab>
<petal-branded-fab size="small" label="Add">
  <svg slot="icon" viewBox="0 0 36 36">
    <ellipse cx="18" cy="10" rx="5" ry="8" fill="#F48FB1"></ellipse>
    <ellipse cx="26" cy="18" rx="8" ry="5" fill="#EC407A"></ellipse>
    <ellipse cx="18" cy="26" rx="5" ry="8" fill="#F06292"></ellipse>
    <ellipse cx="10" cy="18" rx="8" ry="5" fill="#F8BBD0"></ellipse>
    <circle cx="18" cy="18" r="4" fill="#FFD54F"></circle>
  </svg>
</petal-branded-fab>
PropertyAttributeTypeDefaultDescription
variantvariantFabVariant'surface'The FAB color variant to render.
sizesizeFabSize'medium'The size of the FAB.
NOTE: Branded FABs cannot be sized to small, and Extended FABs do not have different sizes.
labellabelstring''The text to display on the FAB.
loweredloweredbooleanfalseLowers the FAB's elevation.

PetalBrandedFab <petal-branded-fab>

Link to “PetalBrandedFab <petal-branded-fab>”
PropertyAttributeTypeDefaultDescription
variantvariantFabVariant'surface'The FAB color variant to render.
sizesizeFabSize'medium'The size of the FAB.
NOTE: Branded FABs cannot be sized to small, and Extended FABs do not have different sizes.
labellabelstring''The text to display on the FAB.
loweredloweredbooleanfalseLowers the FAB's elevation.
MethodParametersReturnsDescription
getRenderClassesNone{ primary: boolean; secondary: boolean; tertiary: boolean; small: boolean; 'filled-primary': boolean; 'filled-secondary': boolean; 'filled-tertiary': boolean; lowered: boolean; large: boolean; extended: boolean; }
About
IntroductionQuick StartMaterial 3 ExpressiveRoadmapSupportBundle SizesDesign tokensToken update v34LicensingVisual testingReleasing
Theming
Material ThemingColorTypographyShape
Components
Button groupButtonsCheckboxChipsDialogsFloating action button (FAB)Icon ButtonsListsMenusProgress indicatorsRadioRippleSelectSlidersSwitchTabsText field