---
name: unity-setup-feature-plugin
description: >
  Wire Unity into a feature plugin in the hr-apps monorepo. Run the
  setup-unity nx generator (installs packages, configures TailwindCSS 4,
  sets up TS types, adds providers). Provider order at app root: the host's
  i18next provider with Unity's `unity` namespace → I18nProvider
  (react-aria-components) → UnityIconsProvider. Import
  @payfit/unity-themes/css/unity.css once. In HR Apps, @payfit/i18n loads
  Unity's catalogs; do not import their JSON or create another instance in
  the feature. Unity must not depend on @payfit/i18n.
metadata:
  type: lifecycle
  library: '@payfit/unity-components'
  library_version: '2.x'
sources:
  - 'PayFit/hr-apps:libs/shared/unity/components/src/docs/tutorials/Getting Started.mdx'
  - 'PayFit/hr-apps:libs/shared/unity/icons/src/components/icons-provider/UnityIconsProvider.tsx'
  - 'PayFit/hr-apps:libs/shared/unity/themes/docs/migration/0-to-1.mdx'
  - 'PayFit/hr-apps:libs/shared/unity/components/i18n/'
---

Bootstrap Unity for a feature plugin once. After this skill completes you
can import any export from `@payfit/unity-components` without further
wiring.

Keep Unity and business messages on the host's existing i18next instance so
they follow the same locale. HR Apps loads the `unity` namespace through
`@payfit/i18n`; its Storybook addon exposes `loadTranslations('unity')` for
interaction-test labels. Do not add a Unity-specific hook or provider.

## If in hr-apps, use this generator

```bash
pnpm nx g @payfit/nx-tools:setup-unity \
  --project=<YOUR_PROJECT> \
  --withIcons --withIllustrations
```

The generator installs `@payfit/unity-components`, `@payfit/unity-themes`,
`@payfit/unity-icons`, and (with `--withIllustrations`)
`@payfit/unity-illustrations` from the workspace catalog; wires the
TailwindCSS 4 plugin with the Unity theme preset; adds the
`@payfit/unity-themes` reference to the project `tsconfig`; and
mounts the providers in the correct order at the project entry. Do not
hand-edit those files afterwards — re-run the generator.

Companion generator:

```bash
# Storybook for the project
pnpm nx g @payfit/nx-tools:storybook --project=<YOUR_PROJECT>
```

## Setup (manual fallback)

Use only when the generator cannot run (e.g. setting up a sample app
outside the monorepo).

All details in guide: libs/shared/unity/components/src/docs/tutorials/Getting Started.mdx
