# UI Components > Component library documentation and usage examples for the design system. ## 🧩 Component Architecture All components follow a consistent structure with design tokens, accessibility standards, and responsive behavior. ### Base Component Pattern ```html
``` ### Component CSS Structure ```css /* Block */ .component-name { /* Base styles using design tokens */ } /* Element */ .component-name__element { /* Element styles */ } /* Modifier */ .component-name--variant { /* Variant styles */ } /* State */ .component-name.is-active { /* State styles */ } ``` ## 📋 Form Components ### Buttons Basic button implementation with variants: ```html ``` **CSS Implementation:** ```css .btn { display: inline-flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); border: 1px solid transparent; border-radius: var(--radius-md); font-family: var(--font-family-sans); font-size: var(--text-sm); font-weight: var(--font-medium); text-decoration: none; cursor: pointer; transition: all var(--duration-150) var(--ease-out); &:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; } &:disabled { opacity: 0.5; cursor: not-allowed; } } .btn--primary { background: var(--color-primary); color: white; &:hover:not(:disabled) { background: var(--color-primary-600); } } .btn--secondary { background: var(--color-gray-100); color: var(--color-gray-700); border-color: var(--color-gray-200); &:hover:not(:disabled) { background: var(--color-gray-200); } } .btn--ghost { background: transparent; color: var(--color-gray-600); &:hover:not(:disabled) { background: var(--color-gray-100); } } ``` ### Input Fields Form input components with validation states: ```html
Optional help text for this field
This field is required
``` ## 🎭 Layout Components ### Cards Content containers with consistent styling: ```html

Card Title

Card content goes here...

``` ### Modals Accessible modal dialogs: ```html ``` ## 📊 Data Display ### Tables Data tables with sorting and filtering: ```html
Name Email Actions
John Doe john@example.com
``` ### Stats Cards Dashboard statistics display: ```html
📊
Total Users
1,234
↗ +12% from last month
``` ## 🔔 Feedback Components ### Alerts Status and notification messages: ```html ``` ### Loading States Progress indicators and skeleton screens: ```html
65% Complete
``` ## 🎯 Interactive Components ### Tabs Content organization with tabbed interface: ```html
Content for tab 1
``` ### Dropdowns Menu and selection dropdowns: ```html ``` ## ♿ Accessibility Guidelines ### ARIA Implementation All components include proper ARIA attributes: - `role` attributes for semantic meaning - `aria-label` for accessible names - `aria-describedby` for help text associations - `aria-expanded` for collapsible content - `aria-selected` for selectable items ### Keyboard Navigation Components support keyboard interaction: - **Tab**: Navigate between focusable elements - **Enter/Space**: Activate buttons and links - **Escape**: Close modals and dropdowns - **Arrow Keys**: Navigate within component groups ### Focus Management Proper focus indicators and management: ```css .component:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; } /* Skip focus ring on mouse interaction */ .component:focus:not(:focus-visible) { outline: none; } ``` ## 🎨 Theming All components automatically adapt to theme changes through CSS custom properties: ```css .component { background: var(--surface); color: var(--text-primary); border: 1px solid var(--border); } /* Dark theme automatically applied */ [data-theme="dark"] .component { /* Inherits dark theme tokens */ } ``` ## 📚 Usage Examples ### JavaScript Integration Components work with the framework's JavaScript module system: ```javascript // Auto-initialize components document.querySelectorAll('[data-component="modal"]').forEach(element => { new Modal(element); }); // Event-driven interactions events.delegate('click', '[data-action="show-alert"]', (event, element) => { const message = element.dataset.message; showAlert('success', message); }); ``` ### PHP Template Integration Components integrate with the View system: ```php

``` --- *For design tokens and foundations, see [Design Foundations](foundations.md)* *For CSS architecture details, see [CSS Architecture](css-architecture.md)* *For JavaScript integration, see [JavaScript Modules](javascript.md)*