Articles in this section

How to get started easily with Syncfusion Angular 11 Button Group?

A quick start project that helps you to create an Angular 11 Button Group with a minimal code configurations.


Angular 11 ButtonGroup

The following section explains you how to create a simple angular 11 ButtonGroup component.

Prerequisites

Before start, we need following items to create Angular ButtonGroup in Angular 11 application

Dependencies

The angular 11 ButtonGroup is created from the Syncfusion ej2-splitbuttons package from npmjs, which are distributed in npm as @syncfusion scoped packages.


Creating Angular Project

 

  1. Install Angular cli 11 using following command. 
npm install -g @angular/[email protected] 

Note:

If you would like to follow and run the application in Angular 6 or Angular 5 or Angular 4, you need to replace the CLI command version number with the corresponding angular version number.

  npm install -g @angular/cli@<CLI VERSION>

 

  1. Create a new Angular 11 project using Angular CLI and navigate to that folder.
ng new angular11-app

cd angular11-app 

 

Adding Angular ButtonGroup:

 

  1. After running the Angular 11 application successfully, configure the Angular ButtonGroup in this application. Install Angular ButtonGroup and EJ2 package using the following command.
npm install @syncfusion/ej2-splitbuttons --save 

The --save command will instruct NPM to include a ButtonGroup package in the dependencies section of the package.json.

  1. Import Button from installed package to render button.
  2. Import and inject the other required modules within the providers section of app.module.ts. 
import { BrowserModule } from '@angular/platform-browser';

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

import { ButtonModule } from '@syncfusion/ej2-angular-buttons';

import { AppComponent } from './app.component';

import { enableRipple } from '@syncfusion/ej2-base';

 

enableRipple(true);

 

@NgModule({

  declarations: [

    AppComponent

  ],

  imports: [

    BrowserModule,

    ButtonModule

  ],

  providers: [],

  bootstrap: [AppComponent]

})

export class AppModule {} 

    4. Add the given below angular buttonGroup’s styles in styles.css.

@import "../node_modules/@syncfusion/ej2-base/styles/material.css";

@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css";

@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
  1. Add the angular ButtonGroup component in app.component.ts.
 import { Component } from '@angular/core';

 

@Component({

    selector: 'app-root',

    template: `<div class='e-btn-group'>

             <button ejs-button>HTML</button>

             <button ejs-button>CSS</button>

             <button ejs-button>JAVASCRIPT</button>

             </div>`

})

export class AppComponent {}
  1. Now serve the application using the following command.
ng serve --open 

Once the files are compiled successfully, it will serve the site at localhost:4200

Screenshot:

button-group

 

Change ButtonGroup Orientation

ButtonGroup can be arranged in both vertical and horizontal orientation. By default, it is horizontally oriented. To change to the vertical orientation use the built-in cssClass e-vertical to the target element.

[app.component.ts]

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

 

@Component({

    selector: 'app-root',

    template: `<div class='e-btn-group e-vertical'>

             <button ejs-button>HTML</button>

             <button ejs-button>CSS</button>

             <button ejs-button>JAVASCRIPT</button>

             </div>`

})

export class AppComponent {}

 

Screenshot

Buttongroup-orientation


Conclusion


We hope you enjoyed learning about how to get started easily with Syncfusion Angular 11 Progress Button.

You can refer to our Angular feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. 

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsBoldDesk Support, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied