# Installing (for applications)

> Learn how to enhance your application with Cimpress UI components.

Source: https://ui.cimpress.io/getting-started/developers/installing-for-applications/

:::caution
This guide provides installation instructions for end-user applications. If you want to use Cimpress UI within a
library, skip ahead to the [installation guide for libraries](/getting-started/developers/installing-for-libraries).
:::

## Is this for me?

You **should** use Cimpress UI in your application if:

- you're creating a new React application and you want it to have a Cimpress look and feel
- you're looking to migrate your existing React application from Component Library to a more modern solution

You **may not** use Cimpress UI in your application if:

- your application doesn't use React, or uses a React version older than 16.14

## Project guidelines

We recommend that your application follows our [project guidelines](/dev-guides/project-guidelines) in order to keep the Cimpress ecosystem healthy and modern.

## Requirements

In order to use Cimpress UI, your application must meet the following requirements:

- React >= 16.14
- if you use TypeScript:
  - TypeScript >= 4.7
  - `moduleResolution` set to `node16`, `nodenext`, or `bundler`

Read our [ecosystem support policy](/dev-guides/ecosystem-support) for more information.

## Installing the library

Install the library using your project's package manager:

**npm**

```sh
npm install @cimpress-ui/react
```

**pnpm**

```sh
pnpm add @cimpress-ui/react
```

**Yarn**

```sh
yarn add @cimpress-ui/react
```

## Providing fonts

Cimpress UI components require the Open Sans font. We recommend using [Fontsource](https://fontsource.org/) for installing the font in your application. Alternatively, you could load the font from Google Fonts.

**Fontsource**

1. Install the font using your project's package manager:

   **npm**

   ```sh
   npm install @fontsource-variable/open-sans
   ```

   **pnpm**

   ```sh
   pnpm add @fontsource-variable/open-sans
   ```

   **Yarn**

   ```sh
   yarn add @fontsource-variable/open-sans
   ```

2. Import the font's CSS files into the JS/TS entrypoint of your application:

   ```tsx title="src/main.tsx" ins={5-6}
   import { StrictMode } from 'react';
   import { createRoot } from 'react-dom/client';
   import App from './app.js';

   import '@fontsource-variable/open-sans/wght.css';
   import '@fontsource-variable/open-sans/wght-italic.css';

   createRoot(document.getElementById('root')!).render(
     <StrictMode>
       <App />
     </StrictMode>,
   );
   ```

**Google Fonts**

:::danger
Loading fonts from Google Fonts requires sharing IP addresses of your users with Google, which is considered a privacy violation in European case law.
We discourage use of Google Fonts unless your users have explicitly consented to sharing their personal information with third-party services.
:::

Add the following snippet in your root HTML file:

```html title="index.html" ins={8-13}
<!doctype html>
<html lang="en">
  <head>
    <title>My App</title>

    ...

    <link rel="preconnect" href="https://fonts.googleapis.com" />
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
    <link
      href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap"
      rel="stylesheet"
    />
  </head>
  <body>
    ...
  </body>
</html>
```

## Including CSS

Cimpress UI provides its styles in a separate CSS file which your application needs to import.
The library applies no global styles - instead, all styles are scoped to a `data-cim-style-root` attribute.
You must apply this attribute to an element within your application's DOM in order for the styles to take effect.
The styles will only be applied to the element marked with the attribute, and to all its descendants.

For most applications, you should import `@cimpress-ui/react/styles.css` which includes all necessary styles.
For advanced use cases, the library also provides separate stylesheets:

- `@cimpress-ui/react/normalize.css` - a normalization stylesheet (commonly called a "CSS reset") that provides consistent styling across browsers
- `@cimpress-ui/react/core.css` - the main stylesheet containing Cimpress UI's design tokens and component styles

1. Import the library styles into the JS/TS entrypoint of your application, right after the font imports:

   ```tsx title="src/main.tsx" ins={7}
   import { StrictMode } from 'react';
   import { createRoot } from 'react-dom/client';
   import App from './app.js';

   import '@fontsource-variable/open-sans/wght.css';
   import '@fontsource-variable/open-sans/wght-italic.css';
   import '@cimpress-ui/react/styles.css';

   createRoot(document.getElementById('root')!).render(
     <StrictMode>
       <App />
     </StrictMode>,
   );
   ```

2. Add a `data-cim-style-root` attribute to a chosen element within your DOM tree. For new applications, this will usually be the `html` element in your root HTML file:

   ```html title="index.html" ins=" data-cim-style-root"
   <!doctype html>
   <html lang="en" data-cim-style-root>
     <head>
       <title>My App</title>

       ...
     </head>
     <body>
       ...
     </body>
   </html>
   ```

## Next steps

If you're creating a new application with Cimpress UI, explore our Foundations, Developer Guides, and Components documentation.

If you're migrating your application from Component Library, proceed to the [migration guide](/cl-migration/overview).
