# Component Library
## One-Liner
**A comprehensive collection of reusable UI components built with Radix UI primitives and Tailwind CSS, following shadcn/ui patterns for consistent, accessible, and customizable interfaces.**
---
## Overview
**Location**: `ccw/frontend/src/components/ui/`
**Purpose**: Provides a consistent set of UI components for building the CCW frontend application.
**Technology Stack**:
- **Radix UI**: Unstyled, accessible component primitives
- **Tailwind CSS**: Utility-first styling with custom theme
- **class-variance-authority (CVA)**: Type-safe variant prop management
- **Lucide React**: Consistent iconography
---
## Live Demo: Component Gallery
:::demo ComponentGallery
# component-gallery.tsx
/**
* Component Gallery Demo
* Interactive showcase of all UI components
*/
export function ComponentGallery() {
const [selectedCategory, setSelectedCategory] = React.useState('all')
const [buttonVariant, setButtonVariant] = React.useState('default')
const [switchState, setSwitchState] = React.useState(false)
const [checkboxState, setCheckboxState] = React.useState(false)
const [selectedTab, setSelectedTab] = React.useState('variants')
const categories = [
{ id: 'all', label: 'All Components' },
{ id: 'buttons', label: 'Buttons' },
{ id: 'forms', label: 'Forms' },
{ id: 'feedback', label: 'Feedback' },
{ id: 'navigation', label: 'Navigation' },
{ id: 'overlays', label: 'Overlays' },
]
const components = {
buttons: [
{ name: 'Button', variants: ['default', 'destructive', 'outline', 'secondary', 'ghost', 'link', 'gradient'] },
],
forms: [
{ name: 'Input', type: 'text' },
{ name: 'Textarea', type: 'textarea' },
{ name: 'Select', type: 'select' },
{ name: 'Checkbox', type: 'checkbox' },
{ name: 'Switch', type: 'switch' },
],
feedback: [
{ name: 'Badge', variants: ['default', 'secondary', 'success', 'warning', 'destructive'] },
{ name: 'Progress', type: 'progress' },
{ name: 'Alert', type: 'alert' },
],
navigation: [
{ name: 'Tabs', type: 'tabs' },
{ name: 'Breadcrumb', type: 'breadcrumb' },
],
overlays: [
{ name: 'Dialog', type: 'dialog' },
{ name: 'Drawer', type: 'drawer' },
{ name: 'Dropdown', type: 'dropdown' },
],
}
const buttonVariants = ['default', 'destructive', 'outline', 'secondary', 'ghost', 'link']
return (
{/* Header */}
UI Component Library
Interactive showcase of all available UI components
{/* Category Filter */}
{categories.map((cat) => (
))}
{/* Buttons Section */}
{(selectedCategory === 'all' || selectedCategory === 'buttons') && (
Buttons
{/* Variant Selector */}
{buttonVariants.map((variant) => (
))}
{/* Button Sizes */}
{/* All Button Variants */}
)}
{/* Forms Section */}
{(selectedCategory === 'all' || selectedCategory === 'forms') && (
Form Components
{/* Input */}
{/* Textarea */}
{/* Checkbox */}
{/* Switch */}
{/* Select */}
{/* Form Actions */}
)}
{/* Feedback Section */}
{(selectedCategory === 'all' || selectedCategory === 'feedback') && (
Feedback Components
{/* Badges */}
Default
Secondary
Destructive
Success
Warning
Info
Outline
{/* Progress */}
{/* Alerts */}
⚠
Error occurred
Something went wrong. Please try again.
✓
Success!
Your changes have been saved.
)}
{/* Navigation Section */}
{(selectedCategory === 'all' || selectedCategory === 'navigation') && (
Navigation Components
{/* Tabs */}
{['Overview', 'Documentation', 'API Reference', 'Examples'].map((tab) => (
))}
{/* Breadcrumb */}
)}
{/* Overlays Section */}
{(selectedCategory === 'all' || selectedCategory === 'overlays') && (
Overlay Components
Dialog
Modal dialogs for focused user interactions.
Drawer
Side panels that slide in from screen edges.
Dropdown Menu
Context menus and action lists.
)}
)
}
:::
---
## Available Components
### Form Components
| Component | Description | Props |
|-----------|-------------|-------|
| [Button](/components/ui/button) | Clickable action buttons with variants and sizes | `variant`, `size`, `asChild` |
| [Input](/components/ui/input) | Text input field | `error` |
| [Textarea](/components/ui/textarea) | Multi-line text input | `error` |
| [Select](/components/ui/select) | Dropdown selection (Radix) | Select components |
| [Checkbox](/components/ui/checkbox) | Boolean checkbox (Radix) | `checked`, `onCheckedChange` |
| [Switch](/components/ui/switch) | Toggle switch | `checked`, `onCheckedChange` |
### Layout Components
| Component | Description | Props |
|-----------|-------------|-------|
| [Card](/components/ui/card) | Content container with header/footer | Nested components |
| [Separator](/components/ui/separator) | Visual divider | `orientation` |
| [ScrollArea](/components/ui/scroll-area) | Custom scrollbar container | - |
### Feedback Components
| Component | Description | Props |
|-----------|-------------|-------|
| [Badge](/components/ui/badge) | Status indicator label | `variant` |
| [Progress](/components/ui/progress) | Progress bar | `value` |
| [Alert](/components/ui/alert) | Notification message | `variant` |
| [Toast](/components/ui/toast) | Temporary notification (Radix) | Toast components |
### Navigation Components
| Component | Description | Props |
|-----------|-------------|-------|
| [Tabs](/components/ui/tabs) | Tab navigation (Radix) | Tabs components |
| [TabsNavigation](/components/ui/tabs-navigation) | Custom tab bar | `tabs`, `value`, `onValueChange` |
| [Breadcrumb](/components/ui/breadcrumb) | Navigation breadcrumb | Breadcrumb components |
### Overlay Components
| Component | Description | Props |
|-----------|-------------|-------|
| [Dialog](/components/ui/dialog) | Modal dialog (Radix) | `open`, `onOpenChange` |
| [Drawer](/components/ui/drawer) | Side panel (Radix) | `open`, `onOpenChange` |
| [Dropdown Menu](/components/ui/dropdown) | Context menu (Radix) | Dropdown components |
| [Popover](/components/ui/popover) | Floating content (Radix) | `open`, `onOpenChange` |
| [Tooltip](/components/ui/tooltip) | Hover tooltip (Radix) | `content` |
| [AlertDialog](/components/ui/alert-dialog) | Confirmation dialog (Radix) | Dialog components |
### Disclosure Components
| Component | Description | Props |
|-----------|-------------|-------|
| [Collapsible](/components/ui/collapsible) | Expand/collapse content (Radix) | `open`, `onOpenChange` |
| [Accordion](/components/ui/accordion) | Collapsible sections (Radix) | Accordion components |
---
## Button Variants
The Button component supports 8 variants via CVA (class-variance-authority):
| Variant | Use Case | Preview |
|---------|----------|--------|
| `default` | Primary action | Default |
| `destructive` | Dangerous actions | Destructive |
| `outline` | Secondary action | Outline |
| `secondary` | Less emphasis | Secondary |
| `ghost` | Subtle action | Ghost |
| `link` | Text link | Link |
| `gradient` | Featured action | Gradient |
| `gradientPrimary` | Primary gradient | Primary |
### Button Sizes
| Size | Height | Padding |
|------|--------|---------|
| `sm` | 36px | 12px horizontal |
| `default` | 40px | 16px horizontal |
| `lg` | 44px | 32px horizontal |
| `icon` | 40px | Square (icon only) |
---
## Badge Variants
The Badge component supports 9 variants for different status types:
| Variant | Use Case | Color |
|---------|----------|-------|
| `default` | General info | Primary theme |
| `secondary` | Less emphasis | Secondary theme |
| `destructive` | Error/Danger | Destructive theme |
| `outline` | Subtle | Text color only |
| `success` | Success state | Green |
| `warning` | Warning state | Amber |
| `info` | Information | Blue |
| `review` | Review status | Purple |
| `gradient` | Featured | Brand gradient |
---
## Usage Examples
### Button
```tsx
import { Button } from '@/components/ui/Button'
```
### Input with Error State
```tsx
import { Input } from '@/components/ui/Input'
setName(e.target.value)}
/>
```
### Checkbox
```tsx
import { Checkbox } from '@/components/ui/Checkbox'
```
### Switch
```tsx
import { Switch } from '@/components/ui/Switch'
Enable feature
```
### Card
```tsx
import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from '@/components/ui/Card'
Card Title
Brief description here
Main content goes here.
```
### Badge
```tsx
import { Badge, badgeVariants } from '@/components/ui/Badge'
Completed
Pending
Failed
```
---
## Accessibility
All components follow Radix UI's accessibility standards:
- **Keyboard Navigation**: All interactive components are fully keyboard accessible
- **ARIA Attributes**: Proper roles, states, and properties
- **Screen Reader Support**: Semantic HTML and ARIA labels
- **Focus Management**: Visible focus indicators and logical tab order
- **Color Contrast**: WCAG AA compliant color combinations
### Keyboard Shortcuts
| Component | Keys |
|-----------|-------|
| Button | Enter, Space |
| Checkbox/Switch | Space to toggle |
| Select | Arrow keys, Enter to select, Esc to close |
| Dialog | Esc to close |
| Tabs | Arrow keys to navigate |
| Dropdown | Arrow keys, Enter to select |
---
## Related Links
- [Radix UI Primitives](https://www.radix-ui.com/) - Headless UI component library
- [Tailwind CSS](https://tailwindcss.com/) - Utility-first CSS framework
- [shadcn/ui](https://ui.shadcn.com/) - Component patterns reference
- [CVA Documentation](https://cva.style/) - Class Variance Authority