Skip to content

Admin UI Kit

1. Document Control

PropertyValue
Package@nx-app/admin-ui-kit
Version0.0.0
TypeComponent Library
Based OnShadcn/UI, Radix UI
RuntimeReact 19

2. Scope & Objectives

2.1. Scope

This package is the single source of truth for UI components within the BANA ecosystem. It exports stateless, accessible, and styled components used by the Back Office Client and the Back Office (BO) application.

2.2. Objectives

  • Visual Consistency: Identical branding (colors, typography, spacing) across apps.
  • Accessibility (a11y): Keyboard navigable and screen-reader friendly (WAI-ARIA via Radix).
  • Efficiency: Ready-to-use building blocks for rapid development.
  • Tree-Shaking: Named exports for optimal bundle size.

3. Technology Stack

3.1. Core Dependencies

TechnologyVersionPurpose
React^19.0.0UI Framework (peer)
Tailwind CSS>=4.0.0Styling (peer)
TypeScript^5Type Safety

3.2. Styling Utilities

TechnologyVersionPurpose
class-variance-authority^0.7.1Component Variants
clsx^2.1.1Class Composition
tailwind-merge^3.4.0Class Merging
tw-animate-css^1.4.0Animation Classes

3.3. Radix UI Primitives

ComponentVersionPurpose
@radix-ui/react-accordion^1.2.12Expandable Sections
@radix-ui/react-alert-dialog^1.1.15Confirmation Dialogs
@radix-ui/react-avatar^1.1.11User Avatars
@radix-ui/react-checkbox^1.3.3Checkboxes
@radix-ui/react-collapsible^1.1.12Collapsible Panels
@radix-ui/react-context-menu^2.2.16Right-Click Menus
@radix-ui/react-dialog^1.1.15Modal Dialogs
@radix-ui/react-dropdown-menu^2.1.16Dropdown Menus
@radix-ui/react-label^2.1.8Form Labels
@radix-ui/react-popover^1.1.15Floating Panels
@radix-ui/react-radio-group^1.3.8Radio Buttons
@radix-ui/react-scroll-area^1.2.10Custom Scrollbars
@radix-ui/react-select^2.2.6Dropdowns
@radix-ui/react-separator^1.1.8Visual Dividers
@radix-ui/react-slot^1.2.4Component Slots
@radix-ui/react-switch^1.2.6Toggle Switches
@radix-ui/react-tabs^1.1.13Tab Navigation
@radix-ui/react-tooltip^1.2.8Tooltips

3.4. Additional Components

TechnologyVersionPurpose
lucide-react^0.562.0Icon Library
vaul^1.1.2Drawer Component
sonner^2.0.7Toast Notifications
react-day-picker^9.11.1Calendar/Date Picker
cmdk^1.1.1Command Palette

3.5. Development Tools

TechnologyVersionPurpose
shadcn^3.5.1Component CLI
tsc-alias^1.8.16Path Alias Resolution
@venizia/dev-configs^0.0.5-0Shared ESLint/Prettier

4. Project Structure

apps/admin-ui-kit/
├── src/
│   ├── components/                 # Component Source
│   │   ├── core/                   # Core Components
│   │   │   ├── backdrop/           # Overlay backdrop
│   │   │   └── common/             # Shared components
│   │   ├── icons/                  # Custom Icons
│   │   └── shadcn/                 # shadcn/ui Components (38 files)
│   │       ├── accordion.tsx
│   │       ├── alert-dialog.tsx
│   │       ├── avatar.tsx
│   │       ├── badge.tsx
│   │       ├── breadcrumb.tsx
│   │       ├── button-group.tsx
│   │       ├── button.tsx
│   │       ├── calendar.tsx
│   │       ├── card.tsx
│   │       ├── checkbox.tsx
│   │       ├── collapsible.tsx
│   │       ├── command.tsx
│   │       ├── context-menu.tsx
│   │       ├── dialog.tsx
│   │       ├── drawer.tsx
│   │       ├── dropdown-menu.tsx
│   │       ├── empty.tsx
│   │       ├── field.tsx
│   │       ├── input-group.tsx
│   │       ├── input.tsx
│   │       ├── kbd.tsx
│   │       ├── label.tsx
│   │       ├── popover.tsx
│   │       ├── radio-group.tsx
│   │       ├── scroll-area.tsx
│   │       ├── select.tsx
│   │       ├── separator.tsx
│   │       ├── sheet.tsx
│   │       ├── sidebar.tsx
│   │       ├── skeleton.tsx
│   │       ├── spinner.tsx
│   │       ├── switch.tsx
│   │       ├── table.tsx
│   │       ├── tabs.tsx
│   │       ├── textarea.tsx
│   │       └── tooltip.tsx
│   ├── hooks/                      # Custom Hooks
│   │   └── use-mobile.ts           # Mobile detection
│   ├── styles/                     # CSS Exports
│   ├── utilities/                  # Utility Functions
│   │   └── tw.utility.ts           # Tailwind merge utility
│   ├── generate-index.ts           # Index generator script
│   └── index.ts                    # Package exports
├── scripts/                        # Build scripts
├── dist/                           # Build output
└── package.json

5. Component Categories

5.1. Atoms (Base Components)

ComponentDescriptionVariants
ButtonInteractive buttondefault, destructive, outline, secondary, ghost, link
InputText input field-
LabelForm label-
BadgeStatus indicatorMultiple color variants
CheckboxBoolean selection-
SwitchToggle control-
SeparatorVisual dividerhorizontal, vertical
SkeletonLoading placeholder-
SpinnerLoading indicator-

5.2. Molecules (Composite Components)

ComponentDescriptionFeatures
CardContent containerHeader, content, footer slots
Alert DialogConfirmation modalAction/Cancel buttons
DialogModal overlayTitle, description, close
PopoverFloating contentTrigger-based positioning
TooltipHover informationDelay, positioning
Dropdown MenuAction menuItems, separators, sub-menus
SelectDropdown selectionSearch, groups, multi-select
TabsTab navigationContent panels
AccordionExpandable sectionsSingle/multi expand

5.3. Organisms (Complex Components)

ComponentDescriptionFeatures
CalendarDate pickerRange selection, navigation
CommandCommand paletteSearch, keyboard shortcuts
SidebarNavigation sidebarCollapsible, groups
TableData tableHeaders, rows, cells
SheetSlide-out panelSide positioning
DrawerBottom drawerSwipe gestures

5.4. Custom Components

ComponentDescription
BackdropOverlay backdrop
ComingSoonPlaceholder component
ButtonGroupButton grouping
InputGroupInput with addons
FieldForm field wrapper
EmptyEmpty state display
KbdKeyboard shortcut display

6. Component Implementation Pattern

6.1. Variant System

Components use class-variance-authority (CVA) for variant management:

typescript
const buttonVariants = cva(
  "inline-flex items-center justify-center ...",
  {
    variants: {
      variant: {
        default: 'bg-primary text-primary-foreground hover:bg-primary/90',
        destructive: 'bg-destructive text-white hover:bg-destructive/90',
        outline: 'border bg-background shadow-xs hover:bg-accent',
        secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
        ghost: 'hover:bg-accent hover:text-accent-foreground',
        link: 'text-primary underline-offset-4 hover:underline',
      },
      size: {
        default: 'h-9 px-4 py-2',
        lg: 'h-10 rounded-md px-6',
        sm: 'h-8 rounded-md gap-1.5 py-1.5 px-2.5',
        xs: 'h-7 rounded-md gap-1.5 px-1.5 py-1',
        icon: 'size-9',
      },
    },
    defaultVariants: {
      variant: 'default',
      size: 'default',
    },
  },
);

6.2. Class Utility

The cn utility merges Tailwind classes intelligently:

typescript
import clsx, { ClassValue } from 'clsx';
import { twMerge } from 'tailwind-merge';

export const cn = (...inputs: ClassValue[]) => {
  return twMerge(clsx(inputs));
};

6.3. Component Structure

typescript
function Button({
  className,
  variant,
  size,
  asChild = false,
  ...props
}: React.ComponentProps<'button'> &
  VariantProps<typeof buttonVariants> & {
    asChild?: boolean;
  }) {
  const Comp = asChild ? Slot : 'button';

  return (
    <Comp
      data-slot="button"
      className={cn(buttonVariants({ variant, size, className }))}
      {...props}
    />
  );
}

7. Button Variants

7.1. Visual Variants

VariantStyleUse Case
defaultPrimary backgroundPrimary actions
destructiveRed/danger colorDelete, remove actions
outlineBorder onlySecondary actions
secondaryMuted backgroundAlternative actions
ghostNo backgroundSubtle actions
linkText onlyNavigation links
default-activeActive primarySelected state

7.2. Size Variants

SizeHeightUse Case
default36px (h-9)Standard buttons
lg40px (h-10)Prominent buttons
sm32px (h-8)Compact buttons
xs28px (h-7)Very compact
icon36x36pxIcon-only buttons
icon-sm32x32pxSmall icon buttons
icon-lg40x40pxLarge icon buttons
icon-xs28x28pxVery small icon buttons
icon-xxs20x20pxMinimal icon buttons

8. Hooks

8.1. useMobile

Detects mobile viewport for responsive behavior:

typescript
import { useMobile } from '@nx-app/admin-ui-kit';

const isMobile = useMobile();

9. Usage

9.1. Installation

The package is linked via Bun workspace protocols:

json
{
  "dependencies": {
    "@nx-app/admin-ui-kit": "workspace:*"
  }
}

9.2. Import Pattern

Named exports support tree-shaking:

tsx
import {
  Button,
  Card,
  CardContent,
  CardHeader,
  Dialog,
  DialogContent,
  DialogTrigger,
} from '@nx-app/admin-ui-kit';

9.3. Customization

Components accept className for Tailwind overrides:

tsx
<Button className="bg-red-500 hover:bg-red-600">
  Critical Action
</Button>

9.4. Composition with Radix Slot

Use asChild for component composition:

tsx
<Button asChild>
  <Link href="/dashboard">Go to Dashboard</Link>
</Button>

10. Design Tokens

10.1. Color System

TokenPurpose
primaryBrand color
primary-foregroundText on primary
secondarySecondary actions
secondary-foregroundText on secondary
destructiveDanger/delete actions
mutedSubtle backgrounds
muted-foregroundSubtle text
accentHighlights
accent-foregroundText on accent
backgroundPage background
foregroundPrimary text
cardCard backgrounds
card-foregroundCard text
popoverPopover backgrounds
popover-foregroundPopover text
borderBorder color
inputInput borders
ringFocus rings

10.2. Spacing & Radius

TokenValueUsage
radiusConfigurableBorder radius

11. Exports

11.1. Package Exports

json
{
  "exports": {
    ".": {
      "import": "./dist/index.js",
      "types": "./dist/index.d.ts"
    },
    "./styles/*": "./src/styles/*"
  }
}

11.2. Side Effects

CSS files are marked as side effects for proper bundling:

json
{
  "sideEffects": ["**/*.css"]
}

12. Build & Scripts

12.1. Available Scripts

ScriptCommandPurpose
gen:indexbun ./src/generate-index.tsAuto-generate index.ts
buildsh ./scripts/build.shProduction build
rebuildbun run gen:index && sh ./scripts/rebuild.shFull rebuild
cleansh ./scripts/clean.shClean dist folder
lintbun run eslint && bun run prettier:cliRun linters
lint:fixFix lint issuesAuto-fix

12.2. Index Generation

Components are auto-exported via generate-index.ts:

typescript
// 🚀 AUTO GENERATE - DON'T EDIT THIS FILE

// Exports from components
export * from "./components/shadcn/button";
export * from "./components/shadcn/card";
// ... more exports

// Exports from hooks
export * from "./hooks/use-mobile";

// Exports from utilities
export * from "./utilities/tw.utility";

13. Consumers

13.1. Applications Using Admin UI Kit

ApplicationUsage
client (Back Office)Full component library
bo (Back Office Internal)Full component library

13.2. Not Used In

ApplicationReason
sale-renderer (POS UI)Has own shadcn components

14. Code Statistics

MetricCount
Component Files40+
shadcn Components38
Custom Components4
Icons2
Hooks1
Utilities1
Radix Primitives18

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.