Search results

Getting started with React ProgressButton component

This section explains how to create a simple ProgressButton and to configure it.

Dependencies

The list of dependencies required to use the ProgressButton component in your application is given as follows:

|-- @syncfusion/ej2-react-splitbuttons
    |-- @syncfusion/ej2-react-base
    |-- @syncfusion/ej2-base
    |-- @syncfusion/ej2-splitbuttons
        |-- @syncfusion/ej2-popups
            |-- @syncfusion/ej2-buttons

Installation and configuration

You can use create-react-app to setup the applications. To install create-react-app run the following command.

npm install -g create-react-app

Start a new project using create-react-app command as follows

create-react-app quickstart --scripts-version=react-scripts-ts

cd quickstart
create-react-app quickstart

cd quickstart

‘react-scripts-ts’ is used for creating React app with typescript.

Adding syncfusion packages

All the available Essential JS 2 packages are published in npmjs.com public registry. You can choose the component that you want to install.

To install ProgressButton component, use the following command

npm install @syncfusion/ej2-react-splitbuttons –save

Adding ProgressButton component

Now, you can start adding ProgressButton component in the application. For getting started, add the ProgressButton component in src/App.tsx file using following code.

Add the below code in the src/App.tsx to initialize the ProgressButton.

import { ProgressButtonComponent } from '@syncfusion/ej2-react-splitbuttons';
import * as React from 'react';
import './App.css';

// To render ProgressButton.
export default class App extends React.Component<{}, {}> {

  public render() {
    return (
      <div>
        <ProgressButtonComponent content='Spin Left' />
      </div>
    );
  }
}
import { ProgressButtonComponent } from '@syncfusion/ej2-react-splitbuttons';
import * as React from 'react';
import './App.css';
// To render ProgressButton.
export default class App extends React.Component {
    render() {
        return (<div>
        <ProgressButtonComponent content='Spin Left'/>
      </div>);
    }
}

Adding CSS reference

Import the ProgressButton component required CSS references as follows in src/App.css.

/* import the ProgressButton dependency styles */
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/material.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css";

Run the application

After completing the configuration required to render a basic ProgressButton, run the following command to display the output in your default browser.

npm start
Source
Preview
app.tsx
index.html
app.jsx
import { ProgressButtonComponent } from '@syncfusion/ej2-react-splitbuttons';
import * as React from 'react';
import * as ReactDom from 'react-dom';

// To render ProgressButton.
class App extends React.Component<{}, {}> {

  public render() {
    return (
    <div>
      <ProgressButtonComponent content='Spin Left'/>
      </div>
    );
  }
}
ReactDom.render(<App />,document.getElementById('progress-button'));
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion React Progress Button</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="This demo for React Progress button has progress indicator and spinner. It supports texts, icons, styles, sizes, positions, and its customization." />
    <meta name="author" content="Syncfusion" />
    <link href="//cdn.syncfusion.com/ej2/ej2-base/styles/material.css" rel="stylesheet" />
    <link href="//cdn.syncfusion.com/ej2/ej2-buttons/styles/material.css" rel="stylesheet" />
    <link href="//cdn.syncfusion.com/ej2/ej2-popups/styles/material.css" rel="stylesheet" />
    <link href="//cdn.syncfusion.com/ej2/ej2-splitbuttons/styles/material.css" rel="stylesheet" />
    <link href="index.css" rel="stylesheet" />
    <link href="spinner.css" rel="stylesheet" />
    <link href="progress.css" rel="stylesheet" />
    <link href="icon.css" rel="stylesheet" />
    <link href="events.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
</head>

<body>
        <div id='progress-button'>
            <div id='loader'>Loading....</div>
        </div>
</body>

</html>
import { ProgressButtonComponent } from '@syncfusion/ej2-react-splitbuttons';
import * as React from 'react';
import * as ReactDom from 'react-dom';
// To render ProgressButton.
class App extends React.Component {
    render() {
        return (<div>
      <ProgressButtonComponent content='Spin Left'/>
      </div>);
    }
}
ReactDom.render(<App />, document.getElementById('progress-button'));

ProgressButton supports different styles, types and sizes like Button. In addition, it also supports top and bottom icon positions.

See Also