Installation
The Harness Canary UI library provides a comprehensive set of components, hooks, and utilities to build consistent UIs that match the Harness design system.
npm install @harnessio/ui
yarn add @harnessio/ui
pnpm add @harnessio/ui
Peer Dependencies
The library requires the following peer dependencies:
{ "react": ">=17", "react-router-dom": ">=5"}
Make sure to install these dependencies if they are not already in your project.
Setting Up Tailwind CSS
Harness Canary UI is built with Tailwind CSS. You’ll need to configure your tailwind.config.js to include the UI library’s configuration:
Importing Styles
Import the UI library’s styles in your main CSS file or entry point:
// In your entry file (e.g., main.jsx, App.jsx, etc.)import "@harnessio/ui/styles.css";
Usage
The library provides multiple entry points for different types of exports:
// Import componentsimport { Button, Text, Badge } from '@harnessio/ui/components';
// Import hooksimport { useMediaQuery, useDisclosure } from '@harnessio/ui/hooks';
// Import utilitiesimport { cn, formatDate } from '@harnessio/ui/utils';
// Import views (pre-built layouts and complex components)import { DataTable, PageLayout } from '@harnessio/ui/views';
// Import typesimport type { ButtonProps, TextVariants } from '@harnessio/ui/types';
Additional Resources
Markdown Styles
If you’re using the Markdown components, import the specialized styles:
import "@harnessio/ui/markdown-preview-styles.css";
Verify Installation
Create a simple component to verify your installation is working correctly:
import { Button, Text } from "@harnessio/ui/components";
function TestComponent() { return ( <div className="p-4 space-y-4"> <Text variant="heading-section">Installation Successful!</Text> <Button>Click Me</Button> </div> );}
Troubleshooting
Missing Styles
If components appear unstyled, check that:
- You’ve imported the
@harnessio/ui/styles.css
file - Your Tailwind configuration includes the UI library’s preset
The content paths in your Tailwind config include the UI library components
Type Errors
Ensure you’re using compatible TypeScript versions and that your tsconfig.json
is set up to handle the library’s types.
Version Compatibility
The current version of @harnessio/ui is designed to work with:
- React 17 or higher
- react-router-dom 5 or higher
- Tailwind CSS 3.x
If you’re using earlier versions, you may encounter compatibility issues.