Generic React admin UI components including navigation bars, data tables, status cards, and audit logs for building admin panels and dashboards.
npm install @egintegrations/admin-uiGeneric React admin UI components for building admin panels and dashboards. Includes navigation bars, data tables, status cards, audit logs, and more.
- AdminNavbar: Configurable navigation bar with user info and sign-out
- StatusCard: Generic entity/status display cards with metadata
- DataTable: Feature-rich table component with actions and custom renderers
- AuditLogTable: Specialized audit log viewer with expandable details
- Badge: Status indicator badges with color variants
- Framework-agnostic: Works with Next.js, React Router, or plain React
- TypeScript: Full type safety with comprehensive interfaces
- Tailwind CSS: Styled with Tailwind utility classes
``bash`
npm install @egintegrations/admin-ui
This package requires Tailwind CSS to be configured in your project.
`bash`
npm install react react-dom lucide-react clsx date-fns
Add the package to your tailwind.config.js content paths:
`js`
module.exports = {
content: [
'./src/*/.{js,ts,jsx,tsx}',
'./node_modules/@egintegrations/admin-ui/src/*/.{js,ts,jsx,tsx}',
],
// ... rest of your config
};
Navigation bar for admin panels with configurable nav items and user display.
`tsx
import { AdminNavbar } from '@egintegrations/admin-ui';
import { Activity, Users, FileText } from 'lucide-react';
import Link from 'next/link'; // or your router's Link component
import { usePathname } from 'next/navigation';
function MyAdmin() {
const pathname = usePathname();
return (
currentPath={pathname}
navItems={[
{ href: '/dashboard', label: 'Dashboard', icon: Activity },
{ href: '/users', label: 'Users', icon: Users },
{ href: '/audit', label: 'Audit Logs', icon: FileText },
]}
user={{
displayName: 'John Doe',
email: 'john@example.com',
}}
onSignOut={() => console.log('Sign out')}
linkComponent={Link}
/>
);
}
`
#### Props
- title (required): App title displayed in navbarnavItems
- (required): Array of navigation items with href, label, and optional iconcurrentPath
- (required): Current pathname for active state highlightinguser?
- : User object with displayName and/or emailonSignOut?
- : Sign out button click handlerlinkComponent?
- : Link component for navigation (defaults to )
Display entity status with color-coded badges, metadata, tags, and last activity.
`tsx
import { StatusCard } from '@egintegrations/admin-ui';
title="Production API"
description="Main API server handling production traffic"
status="online"
metadata={[
{ label: 'Type', value: 'API Server' },
{ label: 'Version', value: '2.1.0' },
{ label: 'Region', value: 'us-east-1' },
]}
tags={['production', 'critical', 'monitored']}
lastActivity={new Date()}
onCardClick={(entity) => console.log('Clicked:', entity)}
/>
`
#### Props
- entity (required): The entity object (generic type)title
- (required): Card titledescription?
- : Card descriptionstatus
- (required): Status type ('online' | 'offline' | 'error' | 'maintenance' | 'warning')metadata?
- : Array of label/value pairs to displaytags?
- : Array of tag stringslastActivity?
- : Date or ISO string for last activity timestamponCardClick?
- : Click handler receiving entity objectlinkHref?
- : Link destination (works with linkComponent)linkComponent?
- : Link component wrapper
Generic table component with configurable columns, custom renderers, and row actions.
`tsx
import { DataTable } from '@egintegrations/admin-ui';
import { Badge } from '@egintegrations/admin-ui';
interface Task {
id: string;
name: string;
status: 'pending' | 'running' | 'completed' | 'failed';
createdAt: string;
}
const columns = [
{
key: 'id',
label: 'ID',
render: (value: string) => value.slice(0, 8),
},
{
key: 'name',
label: 'Task Name',
},
{
key: 'status',
label: 'Status',
render: (value: string) => (
{value}
),
},
{
key: 'createdAt',
label: 'Created',
render: (value: string) => new Date(value).toLocaleDateString(),
},
];
const actions = [
{
label: 'View',
onClick: (row: Task) => console.log('View task:', row),
},
{
label: 'Cancel',
onClick: (row: Task) => console.log('Cancel task:', row),
variant: 'danger' as const,
disabled: (row: Task) => row.status === 'completed',
},
];
data={tasks}
actions={actions}
loading={false}
emptyMessage="No tasks found"
onRowClick={(row) => console.log('Row clicked:', row)}
/>
`
#### Props
- columns (required): Array of column definitions with key, label, and optional render functiondata
- (required): Array of data objectsactions?
- : Array of action buttons with label, onClick, variant, and optional disabled functionemptyMessage?
- : Message to display when data is emptyloading?
- : Show loading stateonRowClick?
- : Click handler for rows
Specialized table for displaying audit log entries with expandable details.
`tsx
import { AuditLogTable } from '@egintegrations/admin-ui';
const logs = [
{
id: '1',
timestamp: new Date(),
userId: 'user-123',
userName: 'John Doe',
action: 'CREATE',
resource: 'User',
resourceId: 'user-456',
status: 'success',
details: {
email: 'newuser@example.com',
role: 'admin',
},
},
{
id: '2',
timestamp: '2024-01-20T10:30:00Z',
userId: 'user-789',
userName: 'Jane Smith',
action: 'DELETE',
resource: 'Document',
resourceId: 'doc-123',
status: 'failure',
details: {
error: 'Permission denied',
},
},
];
loading={false}
emptyMessage="No audit logs found"
/>
`
#### Props
- logs (required): Array of audit log entry objectsloading?
- : Show loading stateemptyMessage?
- : Message to display when logs are empty
Status indicator badges with color variants.
`tsx
import { Badge } from '@egintegrations/admin-ui';
`
#### Props
- variant (required): Badge color variant ('success' | 'error' | 'warning' | 'info' | 'default')size?
- : Badge size ('sm' | 'md', defaults to 'md')
`tsx
import React, { useState } from 'react';
import {
AdminNavbar,
StatusCard,
DataTable,
AuditLogTable,
Badge,
} from '@egintegrations/admin-ui';
import { Activity, Server, Database } from 'lucide-react';
import Link from 'next/link';
import { usePathname } from 'next/navigation';
export default function AdminDashboard() {
const pathname = usePathname();
const servers = [
{
id: '1',
name: 'API Server 1',
description: 'Production API',
status: 'online' as const,
metadata: [
{ label: 'Type', value: 'API' },
{ label: 'Version', value: '2.1.0' },
],
tags: ['production', 'critical'],
lastActivity: new Date(),
},
];
const tasks = [
{
id: 'task-1',
name: 'Data Sync',
status: 'completed',
createdAt: new Date().toISOString(),
},
];
const auditLogs = [
{
id: '1',
timestamp: new Date(),
userId: 'user-1',
userName: 'Admin User',
action: 'CREATE',
resource: 'Server',
status: 'success' as const,
},
];
return (
Source Project
Extracted from egi-botnet:
- AdminNavbar:
apps/admin-ui/src/components/Navbar.tsx
- StatusCard: apps/admin-ui/src/components/BotCard.tsx (generalized)
- DataTable: apps/admin-ui/src/components/TaskList.tsx (generalized)
- AuditLogTable: apps/admin-ui/src/components/AuditLog.tsx`Refactored with:
- Framework-agnostic link components
- Generic entity types for StatusCard
- Configurable columns and actions for DataTable
- Removed Next.js-specific dependencies
- Made all components truly reusable
MIT
See the main egi-comp-library repository for contribution guidelines.