Getting Started
28 Jun 20252 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-baseSetup your development environment
To easily set up a React application, use create-vite-app, which provides a faster development environment, smaller bundle sizes, and optimized builds compared to traditional tools like create-react-app. For detailed steps, refer to the Vite installation instructions. Vite sets up your environment using JavaScript and optimizes your application for production.
Note: To create a React application using
create-react-app, refer to this documentation for more details.
To create a new React application, run the following command.
npm create vite@latest my-appTo set-up a React application in TypeScript environment, run the following command.
npm create vite@latest my-app -- --template react-ts
cd my-app
npm run devTo set-up a React application in JavaScript environment, run the following command.
npm create vite@latest my-app -- --template react
cd my-app
npm run devAdding 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 --saveThe 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.tsx 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
Now run the npm run dev command in the console to start the development server. This command compiles your code and serves the application locally, opening it in the browser.
npm run dev