0.6.1 โข Published 6 months ago
@etherisc/ui-kit v0.6.1
@etherisc/ui-kit
A comprehensive React UI component library built with accessibility, type safety, and developer experience in mind. Contains 60+ production-ready components including complete shadcn/ui integration.
โจ Features
- ๐จ Theme-aware - Light/dark mode with DaisyUI + Tailwind CSS
- โก shadcn/ui Integration - Complete set of shadcn components with Radix UI primitives
- โฟ Accessible - WCAG 2.1 AA compliant with axe-core testing
- ๐ง Type-safe - Full TypeScript support with comprehensive interfaces
- ๐ฑ Responsive - Mobile-first design patterns
- ๐ Internationalized - Built-in i18n support with react-i18next
- ๐ Enhanced Notifications - Advanced toast system with Sonner integration
- ๐งช Well-tested - Unit tests, accessibility tests, and visual regression tests
- ๐ Well-documented - Comprehensive Storybook documentation with 200+ stories
๐ Quick Start
Installation
npm install @etherisc/ui-kit
# or
pnpm add @etherisc/ui-kit
# or
yarn add @etherisc/ui-kitBasic Setup
CSS Import - When Do You Need It?
โ Import the CSS if:
- Your app doesn't use Tailwind CSS
- You're building a vanilla React app
- You want a quick setup without configuring Tailwind
โ Don't import the CSS if:
- Your app already has Tailwind CSS configured
- You have your own CSS variables and Tailwind setup
- You're using DaisyUI with your own theme system
// Import styles in your main entry file
// ONLY if your app doesn't have its own Tailwind CSS setup
import "@etherisc/ui-kit/dist/style.css";
// Wrap your app with providers
import { ThemeProvider, ToastProvider, ErrorBoundary } from "@etherisc/ui-kit";
function App() {
return (
<ErrorBoundary>
<ThemeProvider defaultTheme="light" storageKey="app-theme">
<ToastProvider>{/* Your app content */}</ToastProvider>
</ThemeProvider>
</ErrorBoundary>
);
}Basic Usage
import { Button, TextInput, AppShell } from "@etherisc/ui-kit";
function MyApp() {
return (
<AppShell
logo={<div>My App</div>}
sideNavItems={[
{ label: "Dashboard", href: "/" },
{ label: "Settings", href: "/settings" },
]}
>
<div className="space-y-4">
<h1>Welcome to My App</h1>
<TextInput label="Name" placeholder="Enter your name" />
<Button intent="primary">Get Started</Button>
</div>
</AppShell>
);
}๐ Documentation
For AI Coding Agents
This package is optimized for use by AI coding agents. We provide specialized documentation to ensure seamless integration:
- ๐ค AI Agent Quick Start - Essential setup and patterns (5-minute read)
- ๐ AI Agent Comprehensive Guide - Complete API reference and usage patterns
For Human Developers
- ๐ Storybook Documentation - Interactive component explorer
- ๐ฏ Select Component Guide - Complete guide for using the Select component
- ๐จ Design System - Design tokens, patterns, and guidelines
- ๐ง Development Guide - Contributing and development setup
๐งฉ Component Categories
Layout Components
AppShell- Main application layout with navigationAuthShell- Authentication pages layoutErrorShell- Error pages layoutWizardShell- Multi-step form layoutMainFixedLayout- Fixed-width content layoutDataDenseLayout- Data-heavy interface layoutSheet- Slide-out panel component with multiple positioning optionsSidebar- Collapsible sidebar for navigation and content organizationAspectRatio- Maintain consistent aspect ratios for media contentSeparator- Visual divider between content sectionsCollapsible- Expandable/collapsible content containerAccordion- Vertically stacked expandable sections
Form Controls & Input
Button- Primary interactive element with various styles and statesTextInput- Text input with label and validationNumberInput- Numeric input with min/max validationSelect- Dropdown selection with enhanced featuresCheckbox- Boolean selection with custom stylingRadioGroup- Single selection from multiple optionsComboBox- Searchable dropdown with autocompleteTextArea- Multi-line text inputDatePicker- Date selection with calendar popupDateRangePicker- Date range selectionSliderInput- Range slider inputSpinnerInput- Numeric spinner inputSwitch- Toggle switch for boolean valuesToggle- Pressable toggle buttonToggleGroup- Group of toggle buttons with single/multiple selectionInputOTP- One-time password input with multiple slotsSlider- Range slider for numeric value selection
Editor Components
MarkdownEditor- WYSIWYG markdown editor with securityCodeEditor- Syntax-highlighted code editor
UI Primitives (shadcn/ui Components)
Display & Content
Card- Flexible content container with header, body, and footerAvatar- User profile picture display with fallback supportBadge- Small status indicators and labelsTypography- Comprehensive text styling system with semantic componentsSkeleton- Loading placeholders for better UXProgress- Progress bars and loading indicatorsAlert- Contextual alerts and notificationsTooltip- Hover-triggered contextual information
Navigation & Menus
Breadcrumb- Navigation breadcrumbs with custom separatorsTabs- Tabbed content navigationDropdownMenu- Dropdown menus with nested supportContextMenu- Right-click context menusMenubar- Horizontal menu bar navigationNavigationMenu- Complex navigation with mega-menu supportPagination- Page navigation for large datasets
Data Display & Tables
Table- Comprehensive data tables with sorting and selectionHoverCard- Rich content preview on hoverScrollArea- Custom scrollable areas with styled scrollbars
Dialogs & Overlays
Dialog- Modal dialogs and popup windowsAlertDialog- Confirmation and alert dialogsPopover- Positioned floating content containersCommand- Command palette and search interfaces
Feedback & Status
StatusBadge- Status indicatorsToast- Enhanced notification system powered by SonnerSonner- Advanced toast notifications with rich content supportErrorBoundary- Error handling wrapper
Navigation Components
Breadcrumbs- Navigation breadcrumbsThemeToggle- Light/dark mode switcher
๐จ Design Principles
Accessibility First
- All components meet WCAG 2.1 AA standards
- Comprehensive keyboard navigation support
- Screen reader optimized
- High contrast color schemes
Type Safety
- Full TypeScript support
- Strict prop interfaces
- Comprehensive type exports
Developer Experience
- Consistent API patterns
- Comprehensive error messages
- Excellent IDE support
- Hot reload friendly
Styling Philosophy
- No Tailwind classes in consumer code - Use component props instead
- Semantic color system -
intent="primary"vsclassName="bg-blue-500" - Layout utilities allowed -
className="flex gap-4"for spacing/layout only
๐ง Advanced Usage
Form Handling with React Hook Form
import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import { z } from "zod";
import { Form, FormField, TextInput, Button } from "@etherisc/ui-kit";
const schema = z.object({
email: z.string().email(),
name: z.string().min(2),
});
function MyForm() {
const form = useForm({
resolver: zodResolver(schema),
defaultValues: { email: "", name: "" },
});
return (
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)}>
<FormField
control={form.control}
name="email"
render={({ field }) => (
<TextInput {...field} label="Email" type="email" />
)}
/>
<Button type="submit" intent="primary">
Submit
</Button>
</form>
</Form>
);
}Toast Notifications
The UI kit now supports both traditional toast notifications and enhanced Sonner-powered toasts:
// Traditional toast API
import { useToastContext } from "@etherisc/ui-kit";
function MyComponent() {
const { addToast } = useToastContext();
const handleSuccess = () => {
addToast({
title: "Success!",
description: "Your changes have been saved.",
variant: "success",
});
};
return <Button onClick={handleSuccess}>Save</Button>;
}// Enhanced Sonner API with promise support
import { success, promise as toastPromise } from "@etherisc/ui-kit";
function MyComponent() {
const handleSave = async () => {
const savePromise = saveData();
toastPromise(savePromise, {
loading: "Saving changes...",
success: "Changes saved successfully!",
error: "Failed to save changes",
});
};
const handleQuickSuccess = () => {
success("Quick success message!", {
description: "Operation completed successfully",
duration: 3000,
});
};
return (
<div className="space-x-2">
<Button onClick={handleSave}>Save with Promise</Button>
<Button onClick={handleQuickSuccess}>Quick Success</Button>
</div>
);
}Theme Customization
import { ThemeProvider } from "@etherisc/ui-kit";
function App() {
return (
<ThemeProvider
defaultTheme="dark"
storageKey="my-app-theme"
themes={["light", "dark", "custom"]}
>
{/* Your app */}
</ThemeProvider>
);
}๐ ๏ธ Development
Prerequisites
- Node.js 18+
- pnpm 8+
Setup
# Clone the repository
git clone https://github.com/etherisc/ui-kit.git
cd ui-kit
# Install dependencies
pnpm install
# Start development server
pnpm dev
# Start Storybook
pnpm storybookTesting
# Run unit tests
pnpm test
# Run accessibility tests
pnpm test-storybook
# Run visual regression tests
pnpm playwright testBuilding
# Build the library
pnpm build
# Build Storybook
pnpm build-storybook๐ฆ Package Structure
packages/ui-kit/
โโโ src/
โ โโโ components/ # React components
โ โ โโโ primitives/ # Basic UI elements
โ โ โโโ form/ # Form components
โ โ โโโ feedback/ # Status and notification components
โ โ โโโ navigation/ # Navigation components
โ โโโ layout/ # Layout components
โ โโโ hooks/ # Custom React hooks
โ โโโ providers/ # Context providers
โ โโโ utils/ # Utility functions
โ โโโ theme/ # Theme configuration
โ โโโ docs/ # Documentation pages
โโโ .storybook/ # Storybook configuration
โโโ tests/ # Test files
โโโ docs/ # Additional documentation๐ค Contributing
We welcome contributions! Please see our Contributing Guide for details.
Development Workflow
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests and documentation
- Ensure all tests pass
- Submit a pull request
Code Standards
- TypeScript strict mode
- ESLint + Prettier formatting
- Comprehensive test coverage
- Accessibility compliance
- Semantic commit messages
๐ License
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
๐ Support
- Documentation: Storybook
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Made with โค๏ธ by the Etherisc team