Skip to main content

UI Library Overview

@elcto/ui is a shared React component library for Heimdall applications. It provides a consistent design system with reusable components, design tokens, and utilities.

Installation

The UI library is part of the monorepo workspace. It's automatically available to all platform apps.

For Platform Apps

Add the dependency to your package.json:

{
"dependencies": {
"@elcto/ui": "workspace:*"
}
}

Then run:

pnpm install

Next.js Configuration

Add the package to transpilePackages in your next.config.ts:

const nextConfig: NextConfig = {
transpilePackages: ["@elcto/ui"],
// ... other config
};

Import Styles

Import the design tokens and component styles in your globals.css:

@import "tailwindcss";
@import "@elcto/ui/styles/tokens.css";
@import "@elcto/ui/styles/components.css";

/* Tell Tailwind to scan the shared UI library for classes */
@source "../../../../shared/ui/src/**/*.tsx";

Usage

Importing Components

// Import from components
import { Button, Modal, Alert } from "@elcto/ui/components";

// Import utilities
import { cn } from "@elcto/ui/utils";

Re-exporting in Your App

Create a local components/ui/index.ts to re-export shared components:

// Re-export from shared UI library
export {
Button,
Modal,
Alert,
// ... other components
} from "@elcto/ui/components";

// Re-export cn utility
export { cn } from "@elcto/ui/utils";

Then import from your local module:

import { Button, Alert } from "@/components/ui";

Package Structure

shared/ui/
├── package.json
├── tsconfig.json
└── src/
├── index.ts # Main barrel export
├── components/ # React components
│ ├── Alert/
│ ├── AnimatedBackground/
│ ├── ApiHealthBanner/
│ ├── AppSwitcher/
│ ├── AuditIcons/
│ ├── Avatar/
│ ├── Badge/
│ ├── Banner/
│ ├── BlurredText/
│ ├── Button/
│ ├── Card/
│ ├── Checkbox/
│ ├── CodeInput/
│ ├── DateTimePicker/
│ ├── Dropdown/
│ ├── FloatingInput/
│ ├── Icons/
│ ├── Input/
│ ├── LanguageSwitcher/
│ ├── LoadingSpinner/
│ ├── Logo/
│ ├── Modal/
│ ├── Select/
│ ├── SubMenuBar/
│ ├── SubNav/
│ ├── Table/
│ ├── Toast/
│ ├── Tooltip/
│ └── Turnstile/
├── hooks/
│ └── index.ts # Custom hooks
├── styles/
│ ├── tokens.css # CSS design tokens
│ └── components.css # Component utility classes
├── utils/
│ └── cn.ts # Class name utility
└── types/
└── index.ts # Shared types

Features

  • Dark Theme - Optimized for dark mode interfaces
  • TypeScript - Full type safety with exported types
  • Tailwind CSS - Built with Tailwind for consistency
  • Accessible - ARIA attributes and keyboard navigation
  • Composable - Flexible component APIs

Available Components

ComponentDescription
AlertStatus messages with variants
AnimatedBackgroundAnimated gradient background with particles
ApiHealthBannerReal-time API health monitoring
AppSwitcherApp navigation dropdown
AuditIconIcons for audit events
AvatarUser avatar with fallback
BadgeStatus badges and labels
BannerFull-width notification banners
BlurredTextPrivacy-aware text display
ButtonInteractive buttons with variants
CardContent containers
CheckboxStyled checkbox input
CodeInputOTP/verification code input
DateTimePickerDate, time, datetime picker
DropdownDropdown menus
FloatingInputInputs with floating labels
InputBasic text input
LanguageSwitcherLocale selection dropdown
LoadingSpinner & SpinnerLoading indicators
LogoBrand logo components
ModalDialog windows
Platform IconsSVG icons for platforms
SelectCustom dropdown select
SubMenuBarHorizontal sub-navigation bar below header
SubNavNested navigation tabs
TableData tables with pagination
ToastToast notifications
TooltipHover tooltips
TurnstileCloudflare bot protection

Next Steps