Getting Started
7 Nov 20232 minutes to read
This section explains how to create a simple AppBar, and configure its available functionalities in React.
Dependencies
The following list of dependencies are required to use the AppBar component in your application.
|-- @syncfusion/ej2-react-navigations
|-- @syncfusion/ej2-react-base
|-- @syncfusion/ej2-navigations
|-- @syncfusion/ej2-base
Setup your development environment
To set-up a React application, choose any of the following ways. The best and easiest way is to use the create-react-app. It sets up your development environment in JavaScript and improvise your application for production. Refer to the installation instructions of create-react-app
.
npx create-react-app my-app
cd my-app
npm start
or
yarn create react-app my-app
cd my-app
yarn start
To set-up a React application in TypeScript
environment, run the following command.
npx create-react-app my-app --template typescript
cd my-app
npm start
Besides using the npm package runner tool, also create an application from the npm init
. To begin with the npm init
, upgrade the npm
version to npm 6+
.
npm init react-app my-app
cd my-app
npm start
Adding Syncfusion packages
All the available Essential JS 2 packages are published in npmjs.com
public registry.
To install AppBar
component, use the following command
npm install @syncfusion/ej2-react-navigations --save
npm install @syncfusion/ej2-react-buttons --save
The above command installs AppBar dependencies
which are required to render the component in the React
environment.
Adding Style sheet to the Application
Add AppBar component’s styles as given below in App.css
.
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
Add AppBar to the project
Now, you can create AppBar
component in the application. Add AppBar
component in src/App.ts
file using the following code snippet.
import { AppBarComponent } from "@syncfusion/ej2-react-navigations";
import { ButtonComponent } from '@syncfusion/ej2-react-buttons';
import * as React from "react";
const App = () => {
return (
<div className='control-container'>
<AppBarComponent colorMode="Primary">
<ButtonComponent cssClass='e-inherit menu' iconCss='e-icons e-menu'></ButtonComponent>
<span className="regular">React AppBar</span>
<div className="e-appbar-spacer"></div>
<ButtonComponent cssClass='e-inherit login'>FREE TRIAL</ButtonComponent>
</AppBarComponent>
</div>
);
}
export default App;
Run the application
Run the application in the browser using the following command:
npm start