---
description: It describes how to integrate Mantis theme to existing project.
---

# To Existing Project

Many times, our customers do not want to start using Mantis in a new project instead they wanted to apply Mantis themes to their existing ones. This seems to be challenging for them as every project has different architecture and structure. To resolve this, we have picked one free project from MUI itself and tried to integrate Mantis into it.

**Existing Project that we picked:**

Dashboard: [https://mui.com/material-ui/getting-started/templates/](https://mui.com/material-ui/getting-started/templates/)

Live Preview: [https://mui.com/material-ui/getting-started/templates/dashboard/](https://mui.com/material-ui/getting-started/templates/dashboard/)

In this guide, we are going to apply the Mantis theme to the above project step by step.

{% hint style="warning" %}
Project structures vary widely, making a universal guide unfeasible. To assist, we've selected an MUI project as a foundational reference. Clients can leverage this as a starting point, customizing integration as necessary. However, please note this isn't a strict template to be replicated.
{% endhint %}

### Steps to follow

1. **Backup Your Project:** Before making any changes, create a backup of your existing project to ensure you can revert back in case anything goes wrong.
2. **Install&#x20;**_**dependencies**_**&#x20;and&#x20;**_**development dependencies:**_ To install a list of dependencies and devDependencies in an existing project using npm or Yarn, follow these steps:
   1. **Open a Terminal**: Navigate to the root directory of your project using a terminal or command prompt.
   2. **Review package.json**: Before adding dependencies, it's a good idea to review your project's package.json file to check for any existing dependencies and devDependencies. You can either move or add the following packages:
      1. Dependencies
         * [x] @ant-design/colors
         * [x] @ant-design/icons
         * [x] @emotion/react
         * [x] @emotion/styled
         * [x] @mui/icons-material
         * [x] @mui/lab
         * [x] @mui/material
         * [x] lodash
      2. DevDependencies
         * [x] @types/lodash
3. **Migrate theme to your project:** The following files/folders need to move to your project to achieve Mantis theming
   1.  **Context**

       We need to move ConfigContext to have theme property context like theme color, font, etc.

       * Source Path: _full-version\src\contexts\ConfigContext.tsx_
       * Destination Path: _src\contexts\ConfigContext.tsx_
   2.  **Hooks**

       Hooks can use to access values of the theme and localStorage throughout the project. Two hooks needed to be copied.

       * Source Path:&#x20;
         * _full-version\src\hooks\\_&#x75;seConfig.ts
         * _full-version\src\hooks\\_&#x75;seLocalStorage.ts
       * Destination Path:&#x20;
         * _src\hooks\\_&#x75;seConfig.ts
         * _src\hooks\\_&#x75;seLocalStorage.ts
   3.  **Themes**

       This is the main directory to achieve themes. You need to copy the entire directory to the destination.

       * Source Path: _full-version\src\themes_
       * Destination Path: _src\themes_
   4.  **Types**

       Types related to the theme needed to move as well to avoid errors in the compilation. Not all types are needed but only the following:&#x20;

       * Source Paths:
         * _full-version\src\types\overrides - Entire directory_
         * _full-version\src\types\config.ts_
         * _full-version\src\types\extended.ts_
         * _full-version\src\types\theme.ts_
       * Destination Paths:
         * _src\types\overrides_
         * _src\types\config.ts_
         * _src\types\extended.ts_
         * _src\types\theme.ts_
   5.  **Utility**

       To get color variants and custom shadows, the utility provides functions.

       * Source Path:&#x20;
         * _full-version\src\utils\getColors_.ts
         * _full-version\src\utils\getShadow_.ts
       * Destination Path:&#x20;
         * _src\utils\getColors_.ts
         * _src\utils\getShadow_.ts
   6.  **Config**

       The default configuration of the theme.

       * Source Path: _full-version\src\config.ts_
       * Destination Path: _src\config.ts_
   7.  **TSConfig**

       Configuration related to typescript. Mainly to set '**baseUrl**' but you can also copy an entire file if you need.

       * Source Path: _**tsconfig.json**_
       * Destination Path: _tsconfig.json_
4. **Setup App page:** Once you migrate the files mentioned in the above steps, you need to set up the App component so that linking can be set between the theme and the app. Do the following in the destination project:

{% code title="App.tsx" %}
```typescript
import ThemeCustomization from 'themes';
import Dashboard from './dashboard/Dashboard';

function App() {
  return (
    <ThemeCustomization>
      <Dashboard />
    </ThemeCustomization>
  );
}

export default App;
```
{% endcode %}



That's all you need to follow and your project is ready with the Mantis theme.

***

Following is the live preview for an existing project where we followed the above steps and applied a theme, you can compare it with the existing theme and see the differences:

Live Preview (With Mantis Theme): [https://mantisdashboard.com/react/existing\_theme\_integration/](https://mantisdashboard.io/react/existing_theme_integration/)

Live Preview (Without Mantis Theme): [https://mui.com/material-ui/getting-started/templates/dashboard/](https://mui.com/material-ui/getting-started/templates/dashboard/)



{% hint style="success" %}
You can see that app bar and a few other changes have been visible there. We have also added some additional components on the main page to showcase the Mantis theme on that component.
{% endhint %}

<div data-full-width="false"><figure><img src="https://1311393678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQ1TzyfmEGO2Zgu1zgERP%2Fuploads%2FrdPL4FDG6F0fzPwSaX6e%2Fdesign%20compare.png?alt=media&#x26;token=76b3d8c4-26dc-4ae0-b4d8-cd2ac58bfcf7" alt=""><figcaption><p>Comparison between Applied Mantis Theme (Left) &#x26; default theme (Right side)</p></figcaption></figure></div>

<figure><img src="https://1311393678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQ1TzyfmEGO2Zgu1zgERP%2Fuploads%2FMkPcHiDFKPPXZNdqXiuC%2Fimage.png?alt=media&#x26;token=0946f138-81e1-4092-b51e-972217044515" alt=""><figcaption><p>Applied Mantis theme on components</p></figcaption></figure>
