Overview
Happy Habitat uses DaisyUI v5.1.7 as a component library built on top of TailwindCSS. DaisyUI provides pre-designed, semantic component classes that reduce the need for custom styling while maintaining full customization capabilities.Installation
DaisyUI is installed as a dependency alongside TailwindCSS:package.json
Configuration
Plugin Setup
DaisyUI is configured as a plugin insrc/styles.css using Tailwind v4’s @plugin directive:
src/styles.css
Configuration Options
- themes: Available themes (lemonade, dark, forest, winter, autumn, lofi)
- —default: Default theme (lemonade)
- —prefersdark: Theme used when user prefers dark mode (dark)
- root: CSS selector for theme application (
:root) - logs: Enable console logs for debugging
Theme System
Available Themes
Happy Habitat includes 6 pre-configured themes:- Lemonade (default) - Light, vibrant theme
- Dark - Dark mode theme
- Forest - Nature-inspired green theme
- Winter - Cool, minimal theme
- Autumn - Warm, earthy theme
- Lofi - Calm, low-contrast theme
Theme Switching
The application implements dynamic theme switching via the navbar:nav-bar.component.ts
nav-bar.component.html
Theme Persistence
Theme preference is stored in localStorage:Core Components
Buttons
DaisyUI provides semantic button variants:Forms
Input Fields
Select Dropdowns
Form Validation States
Cards
Cards are used extensively for content containers:Alerts
Alerts provide contextual feedback messages:Real-world Alert Component
notification.component.ts
notification.component.html
Menus
Navigation
Loading Indicators
Join (Button Groups)
Used for pagination and grouped controls:Dividers
Links
Modals
DaisyUI modals are used for dialogs and confirmations:Responsive Modal
Tables
Tables display structured data with zebra striping:Table Variants
Badges
Badges display labels and status indicators:Tooltips
Tooltips provide contextual information on hover:Semantic Color System
DaisyUI provides semantic color classes that adapt to themes:Background Colors
bg-base-100- Primary backgroundbg-base-200- Secondary background (navbar, menu)bg-base-300- Tertiary backgroundbg-primary- Primary brand colorbg-secondary- Secondary brand colorbg-accent- Accent colorbg-neutral- Neutral color
Text Colors
text-base-content- Main text colortext-primary- Primary texttext-secondary- Secondary texttext-accent- Accent text
State Colors
bg-success/text-success- Success statebg-error/text-error- Error statebg-warning/text-warning- Warning statebg-info/text-info- Info state
Component Modifiers
Size Modifiers
Most components support size variants:Style Modifiers
Shape Modifiers
Best Practices
1. Use Semantic Classes
Prefer semantic DaisyUI classes over Tailwind utility combinations:2. Consistent Form Structure
Always wrap form elements inform-control:
3. State Management
Use Angular’s reactive features with DaisyUI classes:4. Theme-Aware Colors
Always use semantic color classes for theme compatibility:5. Component Composition
Combine DaisyUI components with Tailwind utilities:Common Patterns
Login Form Pattern
Notification Pattern
See Notification Component above for implementation.Pagination Pattern
See Join (Button Groups) above for implementation.Modal Pattern
The panic button modal demonstrates a complete modal implementation:panic-button.component.html
Table Pattern
Tables are commonly used for listing data with actions:Customization
Custom Theme Colors
To customize theme colors, you would typically extend the DaisyUI configuration. With Tailwind v4, this is done in CSS:Resources
Next Steps
TailwindCSS
Learn about TailwindCSS utility classes
Component Library
Explore custom Angular components