- React component library for OpenCDx apps
- Tech stack: React 18, NextUI/HeroUI, Framer Motion, Tailwind v3, ESM
- Purpose: shared UI primitives/design system for consistent UX across apps
- Usage examples are available in Storybook
Start here based on what you need:
| What You Need | Read This |
|---|---|
| π First time here? | This README (installation & quick start) |
| π» Developing components? | DEV_GUIDE.md - Complete workflows |
| π§ͺ Writing tests? | TESTING.md - Testing guide & best practices |
| ποΈ Component architecture? | COMPONENT_GUIDELINES.md - Patterns & constraints |
| π Version compatibility? | VERSION_COMPATIBILITY.md - Dependency matrix |
| π Release history? | CHANGELOG.md - Version history |
- Node 20+ and npm 10+
- Peer deps provided by consumer:
- react ^18.3
- react-dom ^18.3
- Bundler that supports ESM and CSS imports (e.g., Vite or Next.js)
- Known-good toolchains: Vite, Next.js 14/15
- Version alignment: framer-motion β₯ 11.18 and NextUI/HeroUI 2.x
npm install
npm run build
npm run storybookNote: use npm ci if you want to keep the exact lockfile state.
- Local tarball install (quick link):
# from ui-library
npm pack --silent # creates ui-library-<ver>.tgz
# in your app
npm i ../ui-library/ui-library-*.tgz-
Workspace linking (monorepo):
- Add ui-library as a workspace and depend on "ui-library": "workspace:*", then install.
-
Example use
import { Button } from 'ui-library';
export default function Page() {
return <Button color="primary">Click me</Button>;
}Wrap your app once with NextUI provider:
import { NextUIProvider } from '@nextui-org/system';
export default function RootLayout({ children }: { children: React.ReactNode }) {
return <NextUIProvider>{children}</NextUIProvider>;
}- ESM/CSS note
- This package is ESM and imports CSS. Use a bundler/runtime (Vite/Next). Nodeβs plain
noderunner will not load it.
- This package is ESM and imports CSS. Use a bundler/runtime (Vite/Next). Nodeβs plain
- Requires tailwindcss and autoprefixer in the consumer app:
// postcss.config.js
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}π― Quick Start - Interactive Development Menu:
./dev.shOpens an interactive menu with 24+ commands organized into 7 categories:
- π¦ Build & Development (build, clean, types)
- π§ͺ Testing (Playwright tests, UI mode, coverage)
- π¨ Storybook (dev server, build)
- π Code Quality (lint, auto-fix)
- π Security & Maintenance (audit, outdated)
- π¦ Package Management (install, clean, tarball)
- π Quick Actions (CI workflow, pre-release checklist)
Perfect for:
- New developers discovering available commands
- Running pre-commit checks (
option 23: CI workflow) - Pre-release validation (
option 24: Pre-release checklist) - Quick access to common tasks without memorizing commands
Build & Development:
npm run build- Type-check and compile librarynpm run lint- Run ESLintnpm run lint:fix- Auto-fix linting issuesnpm run storybook- Start Storybook dev servernpm run build-storybook- Build static Storybook
Testing:
- Playwright Component Testing
npm run test- Run all tests (component + E2E)npm run test:component- Component tests only (~6s)npm run test:ui- Interactive test UInpm run test:headed- Visible browsernpm run test:debug- Inspector
- Vitest Unit Tests (library-focused)
npm run test:unit- Run unit tests (Vitest + Testing Library)npm run coverage:unit- HTML coverage report (coverage/index.html)
Security & Maintenance:
npm run audit- Check production dependencies for vulnerabilitiesnpm run audit:dev- Check all dependencies (including dev)npm run audit:fix- Auto-fix vulnerabilities (safe updates)npm run outdated- List packages with available updates
Quick start:
# Component tests (Playwright CT)
npm run test:component
npm run test:ui
# Unit tests + coverage (Vitest)
npm run test:unit
npm run coverage:unit- Component tests cover UI behavior across browsers.
- Unit tests provide fast, deterministic coverage of
src/**with detailed HTML reports.
π See TESTING.md for both CT and unit testing guides.
- Inside the ui-library folder (recreate lockfile):
rm -rf node_modules dist package-lock.json \
&& npm install --no-audit --no-fund \
&& npm run build \
&& npm run build:types- Inside the ui-library folder (keep existing lockfile):
rm -rf node_modules dist \
&& npm ci --no-audit --no-fund \
&& npm run build \
&& npm run build:typesThis library builds and tests against React 18 (devDependencies), and publishes with peerDependencies requiring react >=18 and react-dom >=18. Consumers choose their exact React version.
If you later move the library to React 19 for development:
- Ensure all transitive deps (@react-aria/, @react-stately/, @nextui-org/*, framer-motion) publish React 19βcompatible peer ranges.
- Bump React devDependencies to 19.x, update dependent packages, then regenerate the lockfile using the βrecreate lockfileβ command above.
Explore all components visually:
npm run storybook # Opens http://localhost:6006- Framework:
@storybook/react-vite - All components have interactive examples
- Build static docs:
npm run build-storybook
π For advanced Storybook setup, see DEV_GUIDE.md
Common issue: Using User inside Button in constrained contexts (Navbar, Dropdown triggers).
Quick solution: Use UserButton composite component:
import { UserButton } from 'ui-library';
<UserButton
userProps={{ name: "John Doe", description: "Admin" }}
buttonProps={{ variant: "light" }}
/>π For complete patterns and compatibility matrix, see COMPONENT_GUIDELINES.md
Common issues:
- Import errors: Ensure using a bundler (Vite/Next.js) and app is ESM
- NextUIProvider missing: Wrap app with
<NextUIProvider> - Peer dependency warnings: Align versions (see VERSION_COMPATIBILITY.md)
- Button ripple errors: Import NextUI theme CSS or use
disableRipple
Quick fixes:
# Clean reinstall
./dev.sh β 19) Clean install
# Or manually
rm -rf node_modules package-lock.json && npm installπ For detailed troubleshooting, see DEV_GUIDE.md
Interactive menu for all development tasks:
./dev.shFeatures:
- 24+ commands in 7 categories (Build, Test, Storybook, Quality, Security, etc.)
- Pre-commit validation (option 23: CI workflow)
- Pre-release checklist (option 24: 5 automated checks)
- Project status dashboard
- Color-coded, user-friendly interface
π For detailed guide and workflows, see DEV_GUIDE.md