@payfit/unity-themes
v3.1.16
Published
Keywords
Readme
Unity Themes
The Unity themes package provides a comprehensive design system using TailwindCSS 4, converting all the design tokens of the Unity design system into TailwindCSS utility classes. This is the foundational part of the unity design system and is heavily used by the components package and other unity packages.
Note: Unity Themes v3 is built for TailwindCSS 4. If you're migrating from v0.x, see MIGRATION-v1.md. For the v3 release, see MIGRATION-v3.md.
Installation
Install and configure this package by following these steps:
Install the package and dependencies
pnpm add tailwindcss @fontsource/{inter,source-serif-4} pnpm add @payfit/unity-themesSet up TailwindCSS in your project
You need to configure TailwindCSS 4 in your project. This can be done using either the Vite plugin or PostCSS plugin:
Import Unity Themes in your main CSS file
/* /path/to/your/main/styles.css */ @import '@payfit/unity-themes/css/unity.css';That's it! The Unity CSS file includes all font imports and TailwindCSS configuration.
Use the utility classes in your elements
<button class="uy:bg-surface-primary uy:text-surface-inverted"> hello! </button>
JavaScript Utilities
If you need to use JavaScript utilities (like uyMerge for class merging), import them normally:
import { uyMerge } from '@payfit/unity-themes'
const className = uyMerge('uy:bg-red-l1', 'uy:bg-blue-l2') // 'uy:bg-blue-500'Usage
Use Unity utility classes with the uy: prefix:
<button
class="uy:bg-surface-primary uy:text-surface-inverted uy:hover:bg-surface-secondary"
>
Hello Unity!
</button>Class Syntax
Unity classes use the uy: prefix and the prefix goes before any modifiers:
<div class="uy:bg-red-l1 uy:hover:bg-red-l2 uy:md:text-lg"></div>CSS properties
Access design tokens directly via CSS custom properties:
const MyComponent = ({ isHighlighted }) => {
const bgColor = isHighlighted ? 'var(--color-grayscale-l9)' : 'transparent'
return (
<div className="uy:transition-colors" style={{ backgroundColor: bgColor }}>
Custom styling with design tokens
</div>
)
}Documentation
- Architecture: Technical details, build process, and internal structure
- Migration guides: Guides for migrating between Unity Themes major versions
- Legacy v0.x: Documentation for the previous version
Design Tokens
Design tokens are sourced from Unity's Figma design system and organized in the tokens/ directory:
tokens/
├── colors.json # Color palette and semantic colors
├── typography.json # Font families, sizes, and text styles
├── spacings.json # Spacing scale and layout values
├── shadows.json # Box shadow definitions
├── radii.json # Border radius values
├── layout.json # Grid and container sizes
├── sizes.json # Component and element sizes
└── text.json # Text-specific tokensDevelopment
# Build the package
pnpm nx run unity-themes:build
# Run tests
pnpm nx run unity-themes:testHow to release manually
Add an emoji below:
- 🦄
- 🏰
In some cases, local hr-apps libraries are not published properly, which fails install for @payfit/payslip-template afterward.
