Icons in Angular Floating action button component

27 Apr 20244 minutes to read

You can customize the icon and text of Angular Floating Action Button(FAB) using iconCss and content properties.

FAB with icon

You can show icon only in Floating Action Button by setting iconCss property. You can show tooltip on hover to show additional details to end-user by setting title attribute.

import { Component } from '@angular/core';

@Component({
    selector: 'app-root',
    template: ` <!-- To Render Floating Action Button with icon only -->
                <button ejs-fab id='fab' iconCss= 'fab-icons fab-icon-people'></button>`
})

export class AppComponent { }

FAB with icon and text

You can show icon along with text in Floating Action Button by setting iconCss and content properties.

import { Component } from '@angular/core';

@Component({
    selector: 'app-root',
    template: `<!-- To Render Floating Action Button with icon and text -->
                <button ejs-fab id='fab' iconCss= 'fab-icons fab-icon-people' content= 'Contacts'></button>`
})

export class AppComponent { }

Icon position

You can change the position of icon when showing along with content by setting iconPosition property. By default, the icon is positioned on the left side together with text.

import { Component } from '@angular/core';

@Component({
    selector: 'app-root',
    template: `<!-- To Render Floating Action Button with icon position -->
                <button ejs-fab id='fab' iconCss= 'fab-icons fab-icon-people' content= 'Contacts' iconPosition= 'Right'></button>`
})

export class AppComponent { }

Below example demonstrates a FAB with icon and text.

import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { FabModule } from '@syncfusion/ej2-angular-buttons'



import { Component } from '@angular/core';

@Component({
imports: [
        
        FabModule
    ],


standalone: true,
    selector: 'app-root',
    template: `<div id="targetElement" style="position:relative;min-height:350px;border:1px solid;">
               </div>
               <!-- To Render Floating Action Button -->
                <button ejs-fab id='fab' iconCss= 'fab-icons fab-icon-people' content= 'Contacts' iconPosition= 'Right' target= '#targetElement'></button>`
})

export class AppComponent { }
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
/* Represents the styles for loader */
#loader {
  color: #008cff;
  height: 40px;
  left: 45%;
  position: absolute;
  top: 45%;
  width: 30%;
}

/* Represents the styles for fab icon */
@font-face {
  font-family: 'fab-icons';
  src: url(data:application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QUEBAIBAQEBAgQEBQUHBwgICQkKCgMW/oN3JgwKCgoJCQgIBwYGBQQEAgEBZAEBAwIJVAECBQUHCQoBUAMHBRAKCQgHBQMCZAAAAAAAEgDeAAEAAAAAAAAAAQAAAAEAAAAAAAEACQABAAEAAAAAAAIABwAKAAEAAAAAAAMACQARAAEAAAAAAAQACQAaAAEAAAAAAAUACwAjAAEAAAAAAAYACQAuAAEAAAAAAAoALAA3AAEAAAAAAAsAEgBjAAMAAQQJAAAAAgB1AAMAAQQJAAEAEgB3AAMAAQQJAAIADgCJAAMAAQQJAAMAEgCXAAMAAQQJAAQAEgCpAAMAAQQJAAUAFgC7AAMAAQQJAAYAEgDRAAMAAQQJAAoAWADjAAMAAQQJAAsAJAE7IEZhYi1JY29uc1JlZ3VsYXJGYWItSWNvbnNGYWItSWNvbnNWZXJzaW9uIDEuMEZhYi1JY29uc0ZvbnQgZ2VuZXJhdGVkIHVzaW5nIFN5bmNmdXNpb24gTWV0cm8gU3R1ZGlvd3d3LnN5bmNmdXNpb24uY29tACAARgBhAGIALQBJAGMAbwBuAHMAUgBlAGcAdQBsAGEAcgBGAGEAYgAtAEkAYwBvAG4AcwBGAGEAYgAtAEkAYwBvAG4AcwBWAGUAcgBzAGkAbwBuACAAMQAuADAARgBhAGIALQBJAGMAbwBuAHMARgBvAG4AdAAgAGcAZQBuAGUAcgBhAHQAZQBkACAAdQBzAGkAbgBnACAAUwB5AG4AYwBmAHUAcwBpAG8AbgAgAE0AZQB0AHIAbwAgAFMAdAB1AGQAaQBvAHcAdwB3AC4AcwB5AG4AYwBmAHUAcwBpAG8AbgAuAGMAbwBtAAAAAAIAAAAAAAAACgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQECAQMBBAEFAQYAA2FkZANtaWMGcGVvcGxlCHNob3BwaW5nAAAA) format('truetype');
  font-weight: normal;
  font-style: normal;
}

[class^="fab-icon-"],
[class*=" fab-icon-"] {
  font-family: 'fab-icons' !important;
  speak: none;
  font-size: 55px;
  font-style: normal;
  font-weight: normal;
  font-variant: normal;
  text-transform: none;
  line-height: inherit;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.fab-icon-people:before {
  content: "\e70a";
}