Gatzi UI – Configuration & Integration
Learn how to install, extend, and configure Gatzi UI in your projects. This guide covers CSS and Tailwind integration, project structure, and best practices for using the design system across multiple apps.
Installation
How to add Gatzi UI to your project
- Install the UI package: Add
@gatzi/uito your project dependencies (usually viapnpm add @gatzi/uiornpm install @gatzi/ui). - Import the CSS: In your app's
globals.css, import the base styles from the UI package. You can either:- Directly import:
@import '@gatzi/ui/globals.css'; - Or copy and extend the CSS in your own
globals.cssfor full control.
- Directly import:
- Extend or override tokens: You can override color tokens, fonts, or any CSS variable in your project's
:rootor.darkselectors to match your brand. - Extend Tailwind config: Import and merge the Tailwind config from
@gatzi/uiinto your project'stailwind.config.jsto ensure all custom utilities and tokens are available.
Project Structure & Usage
How apps consume the UI package
Projects under app/ are set up to consume the shared UI package from packages/ui. This ensures all applications use the same design tokens, components, and configuration, promoting consistency and reducing duplication.
- Each app should import
globals.cssfrom the UI package or extend it in their ownglobals.css. - Tailwind config should be extended to include the UI package's configuration and paths.
- All shared components (atoms, molecules, etc.) are imported from
@ui/aliases.
Extending & Overriding
Customizing tokens, colors, and utilities
- You can override any CSS variable (token) in your project's
:rootor.darkselector to change colors, fonts, or other design aspects. - To add new color utilities or variants, extend
globals.cssand update your Tailwind config accordingly. - Custom utility classes (e.g.,
bg-surface-3/80) can be added or modified in your own CSS and referenced in JSX/TSX with the correct escape sequence.
Tailwind Configuration
Ensuring all tokens and utilities are available
The UI package provides a base Tailwind configuration with custom tokens, colors, and utilities. To use these in your app:
- Import the UI package's Tailwind config and merge it with your own in
tailwind.config.js. - Ensure the
contentarray includes paths to both your app and the UI package components. - Restart your dev server after making changes to the config.
Import Aliases & Usage
How to use @ui/ imports in your app
To use imports like import { Heading } from '@ui/Headings';, you need to configure your project's module resolution:
- In
tsconfig.json(orjsconfig.json), add apathsentry mapping@ui/*to the UI package source directory. - Example:
{ "compilerOptions": { "baseUrl": ".", "paths": { "@repo/ui";: ["../packages/ui/src/*"] } } } - Ensure your build tool (e.g., Next.js, Vite) also resolves these aliases if needed.
- Use these imports in any file under
app/orsrc/to access shared UI components.