Styles in Angular Speed dial component
26 Sep 202412 minutes to read
This section briefs different ways to style SpeedDial component.
SpeedDial button
You can customize the icon and text of Angular Speed Dial button using openIconCss
, closeIconCss
and content
properties.
Icon only
You can use the openIconCss
and closeIconCss
properties to show icons in speed dial button. You can also show tooltip on hover to show additional details to end-user by setting title
attribute.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { SpeedDialModule } from '@syncfusion/ej2-angular-buttons'
import { Component } from '@angular/core';
@Component({
imports: [
SpeedDialModule// Registering EJ2 SpeedDial Module.
],
standalone: true,
selector: 'app-root',
template: `<div id="targetElement" style="position:relative;min-height:350px;border:1px solid;"></div>
<!-- To Render SpeedDial component with icon only -->
<button ejs-speeddial id="speeddial" openIconCss='e-icons e-edit' 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));
Text only
You can show only text in Speed Dial button by setting content
property without setting icon properties..
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { SpeedDialModule } from '@syncfusion/ej2-angular-buttons'
import { Component } from '@angular/core';
@Component({
imports: [
SpeedDialModule// Registering EJ2 SpeedDial Module.
],
standalone: true,
selector: 'app-root',
template: `<div id="targetElement" style="position:relative;min-height:350px;border:1px solid;"></div>
<!-- To Render SpeedDial component with text only -->
<button ejs-speeddial id="speeddial" content='Edit' 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));
Icon with text
You show icon and text in SpeedDial button using openIconCss
, closeIconCss
and content
properties together.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { SpeedDialModule } from '@syncfusion/ej2-angular-buttons'
import { Component } from '@angular/core';
@Component({
imports: [
SpeedDialModule// Registering EJ2 SpeedDial Module.
],
standalone: true,
selector: 'app-root',
template: `<div id="targetElement" style="position:relative;min-height:350px;border:1px solid;"></div>
<!-- To Render SpeedDial component with icon and text -->
<button ejs-speeddial id="speeddial" content='Edit' openIconCss='e-icons e-edit' 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));
Disabled
You can enable or disable the SpeedDial component using disabled
property.
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
template: `<!-- To Render SpeedDial component in disabled state -->
<button ejs-speeddial id="speeddial" content='Edit' [disabled]='true'></button>`
})
export class AppComponent { }
cssClass
The Angular Speed Dial supports the following predefined styles that can be defined using the cssClass
property. You can customize by setting the cssClass
property with the below defined class.
cssClass | Description |
---|---|
e-primary | Used to represent a primary action. |
e-outline | Used to represent an appearance of button with outline. |
e-info | Used to represent an informative action. |
e-success | Used to represent a positive action. |
e-warning | Used to represent an action with caution. |
e-danger | Used to represent a negative action. |
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { SpeedDialModule } from '@syncfusion/ej2-angular-buttons'
import { Component } from '@angular/core';
@Component({
imports: [
SpeedDialModule// Registering EJ2 SpeedDial Module.
],
standalone: true,
selector: 'app-root',
template: `<div id="targetElement" style="position:relative;min-height:350px;border:1px solid;"></div>
<!-- To Render SpeedDial component with applied warning style -->
<button ejs-speeddial id="speeddial" content='Edit' cssClass='e-warning' 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));
Visible
You can set the Speed Dial button to visible/hidden state using visible
property.
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
template: `<!-- To Render SpeedDial component in hidden state -->
<button ejs-speeddial id="speeddial" content='Edit' [visible]='false'></button>`
})
export class AppComponent { }
Tooltip
You can show tooltip on hover to show additional details to end-user by setting title
to Speed Dial button.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { SpeedDialModule } from '@syncfusion/ej2-angular-buttons'
import { Component } from '@angular/core';
import { SpeedDialItemModel } from '@syncfusion/ej2-angular-buttons';
@Component({
imports: [
SpeedDialModule// Registering EJ2 SpeedDial Module.
],
standalone: true,
selector: 'app-root',
template: `<div id="targetElement" style="position:relative;min-height:350px;border:1px solid;"></div>
<!-- To Render SpeedDial component -->
<button ejs-speeddial id="speeddial" openIconCss='e-icons e-edit' [items]='items' target='#targetElement'></button>`
})
export class AppComponent {
// Initialize action items with tooltip
public items: SpeedDialItemModel[] = [
{ iconCss:'e-icons e-cut', title:'Cut' },
{ iconCss:'e-icons e-copy', title:'Copy' },
{ iconCss:'e-icons e-paste', title:'Paste' }
];
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
Opens on hover
You can use opensOnHover
property to open actions items on hover itself. By default action items displayed only when clicking the speed dial button.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { SpeedDialModule } from '@syncfusion/ej2-angular-buttons'
import { Component } from '@angular/core';
import { SpeedDialItemModel } from '@syncfusion/ej2-angular-buttons';
@Component({
imports: [
SpeedDialModule// Registering EJ2 SpeedDial Module.
],
standalone: true,
selector: 'app-root',
template: `<div id="targetElement" style="position:relative;min-height:350px;border:1px solid;"><div>
<!-- To Render SpeedDial component. -->
<button ejs-speeddial id="speeddial" openIconCss='e-icons e-edit' closeIconCss='e-icons e-close' target='#targetElement' [items]='items' [opensOnHover]= 'true'></button>`
})
export class AppComponent {
public items: SpeedDialItemModel[] = [
{ iconCss: 'e-icons e-cut' },
{ iconCss: 'e-icons e-copy' },
{ iconCss: 'e-icons e-paste' }
];
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
Customized icon
You can use the cssClass
property to customize the appearance of the speedDial component in its default primary state. Below example demonstrates the cssClass
property usage in speedDial.
import { Component } from '@angular/core';
import { SpeedDialItemModel } from '@syncfusion/ej2-angular-buttons';
@Component({
selector: 'app-root',
template: `<div id="targetElement" style="position:relative;min-height:350px;border:1px solid;"><div>
<!-- To Render SpeedDial component. -->
<button ejs-speeddial id="speeddial" openIconCss='e-icons e-edit' closeIconCss='e-icons e-close' target='#targetElement' [items]='items' cssClass='custom-css'></button>`
})
export class AppComponent {
public items: SpeedDialItemModel[] = [
{ iconCss: 'e-icons e-cut' },
{ iconCss: 'e-icons e-copy' },
{ iconCss: 'e-icons e-paste' }
];
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { SpeedDialModule } from '@syncfusion/ej2-angular-buttons';
/**
* Module
*/
@NgModule({
imports: [
BrowserModule,
SpeedDialModule// Registering EJ2 SpeedDial Module.
],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';
import 'zone.js';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
/* Represents the styles for loader */
#loader {
color: #008cff;
height: 40px;
left: 45%;
position: absolute;
top: 45%;
width: 30%;
}
/* Represents the styles for speeddial icon */
.custom-css .e-btn-icon {
color: darkgreen;
}