- Dependencies
- Installation and configuration
- Adding Syncfusion® packages
- Adding CSS reference
- Adding ColorPicker to the application
- Run the application
- See Also
Contact Support
Getting Started
27 Jun 20254 minutes to read
The following section explains the required steps to build the ColorPicker component with its basic usage in step-by-step procedure.
Dependencies
The following list of dependencies are required to use the ColorPicker component in your application.
|-- @syncfusion/ej2-react-inputs
|-- @syncfusion/ej2-react-base
|-- @syncfusion/ej2-base
|-- @syncfusion/ej2-inputs
|-- @syncfusion/ej2-popups
|-- @syncfusion/ej2-splitbuttons
Installation and configuration
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-app
To 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 dev
To 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 dev
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. For this application, we are going to use ColorPicker component.
To install ColorPicker component, use the following command
npm install @syncfusion/ej2-react-inputs –save
Adding CSS reference
Import the ColorPicker component’s required CSS references as follows in src/App.css
.
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/material.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/material.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
Adding ColorPicker to the application
Now, you can start adding ColorPicker component to the application. We have added ColorPicker component in src/App.tsx
file using following code.
import { ColorPickerComponent } from '@syncfusion/ej2-react-inputs';
import * as React from "react";
import * as ReactDOM from "react-dom";
import './App.css';
// initializes ColorPicker component
function App() {
return ( <div style=>
<div id='container'>
<div className='wrap'>
<h4>Choose Color</h4>
<ColorPickerComponent id='color-picker'/>
</div>
</div>
</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
The following example shows the default ColorPicker.
import { ColorPickerComponent } from '@syncfusion/ej2-react-inputs';
import * as React from "react";
import * as ReactDOM from "react-dom";
// initializes ColorPicker component.
function App() {
return (<div id='container'>
<div className='wrap'>
<h4>Choose Color</h4>
<ColorPickerComponent id='color-picker'/>
</div>
</div>);
}
;
export default App;
ReactDOM.render(<App />, document.getElementById('element'));
import { ColorPickerComponent } from '@syncfusion/ej2-react-inputs';
import * as React from "react";
import * as ReactDOM from "react-dom";
// initializes ColorPicker component.
function App() {
return (
<div id='container'>
<div className='wrap'>
<h4>Choose Color</h4>
<ColorPickerComponent id='color-picker'/>
</div>
</div>
);
};
export default App;
ReactDOM.render(<App />, document.getElementById('element'));