Getting Started with EJ2 JavaScript Progress Button

23 Nov 20265 minutes to read

This section explains the steps required to create a simple Essential® JS 2 Progress button and demonstrate the basic usage of the Progress button control in a JavaScript application.

Dependencies

The list of dependencies required to use the Progress button component in your application is given below:

|-- @syncfusion/ej2-buttons
    |-- @syncfusion/ej2-base

Setup for local environment

Refer to the following steps to set up your local environment.

Step 1: Create a root folder named my-app for your application.

Step 2: Create a my-app/resources folder to store local scripts and styles files.

Step 3: Open Visual Studio Code and create my-app/index.js and my-app/index.html files to initialize the Essential® JS 2 Progress button control.

Control Initialization

The Essential® JS 2 JavaScript controls can be initialized by using below css styles and scripts

Add Syncfusion® Progress Button CSS Styles and Scripts

Include the following CSS and JavaScript files from CDN in the <head> section of the index.html file. The ej2-base, ej2-popups, ej2-splitbuttons scripts are required dependency packages for the Progress Button component.

Styles(CSS):

https://unpkg.com/@syncfusion/ej2-bootstrap5.3-theme/styles/progress-button/index.css

Scripts (javascript):

https://cdn.syncfusion.com/ej2/35.1.37/ej2-base/dist/global/ej2-base.min.js
https://cdn.syncfusion.com/ej2/35.1.37/ej2-popups/dist/global/ej2-popups.min.js
https://cdn.syncfusion.com/ej2/35.1.37/ej2-buttons/dist/global/ej2-buttons.min.js
https://cdn.syncfusion.com/ej2/35.1.37/ej2-splitbuttons/dist/global/ej2-splitbuttons.min.js

Adding Progress Button component to the application

Add the ProgressButton element and initiate the Syncfusion® JavaScript ProgressButton control in the index.html by using following code.

<!DOCTYPE html>
  <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
                
        <title>Essential JS 2</title>
        <!-- Essential JS 2 ProgressButton's dependency style -->
    <link href="https://unpkg.com/@syncfusion/ej2-bootstrap5.3-theme/styles/progress-button/index.css" rel="stylesheet" />

        <!-- Essential JS 2 ProgressButton's dependency global script -->
       <script src="https://cdn.syncfusion.com/ej2/35.2.12/ej2-base/dist/global/ej2-base.min.js" type="text/javascript"></script>
       <script src="https://cdn.syncfusion.com/ej2/35.2.12/ej2-buttons/dist/global/ej2-buttons.min.js" type="text/javascript"></script>
       <script src="https://cdn.syncfusion.com/ej2/35.2.12/ej2-popups/dist/global/ej2-popups.min.js" type="text/javascript"></script>

       <!-- Essential JS 2 ProgressButton's control global script -->
        <script src="https://cdn.syncfusion.com/ej2/35.2.12/ej2-splitbuttons/dist/global/ej2-splitbuttons.min.js" type="text/javascript"></script>
   </head>
   <body>
       <!--element which is going to render-->
        <button id='spinleft'></button>
        <script>
            ej.base.enableRipple(true);

             // Initialize ProgressButton control.
            var progressButton = new ej.splitbuttons.ProgressButton({content: 'Spin Left'});

            // Render initialized ProgressButton.
            progressButton.appendTo('#spinleft');
        </script>
   </body>
  </html>

Enabling Progress in Button

You can enable the background filler UI by setting the enableProgress property to true:

<!DOCTYPE html>
  <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
                
        <title>Essential JS 2</title>
        <!-- Essential JS 2 ProgressButton's dependency style -->
    <link href="https://unpkg.com/@syncfusion/ej2-bootstrap5.3-theme/styles/progress-button/index.css" rel="stylesheet" />

        <!-- Essential JS 2 ProgressButton's dependency global script -->
       <script src="https://cdn.syncfusion.com/ej2/35.2.12/ej2-base/dist/global/ej2-base.min.js" type="text/javascript"></script>
       <script src="https://cdn.syncfusion.com/ej2/35.2.12/ej2-buttons/dist/global/ej2-buttons.min.js" type="text/javascript"></script>
       <script src="https://cdn.syncfusion.com/ej2/35.2.12/ej2-popups/dist/global/ej2-popups.min.js" type="text/javascript"></script>

       <!-- Essential JS 2 ProgressButton's control global script -->
        <script src="https://cdn.syncfusion.com/ej2/35.2.12/ej2-splitbuttons/dist/global/ej2-splitbuttons.min.js" type="text/javascript"></script>
   </head>
   <body>
       <!--element which is going to render-->
        <button id='spinleft'></button>
        <script>
            ej.base.enableRipple(true);

             // Initialize ProgressButton control.
            var progressButton = new ej.splitbuttons.ProgressButton({content: 'Spin Left', enableProgress: "true"});

            // Render initialized ProgressButton.
            progressButton.appendTo('#spinleft');
        </script>
   </body>
  </html>

See Also