-
Notifications
You must be signed in to change notification settings - Fork 0
Description
DaisyUI Button Customization Documentation Gap
Issue Type
📚 Documentation Enhancement / Developer Experience Improvement
Severity
Medium - Impacts developer productivity and adoption
Summary
While @etherisc/ui-kit correctly integrates DaisyUI, there's insufficient documentation on how to properly customize DaisyUI button colors using the CSS custom property system. This leads developers to attempt traditional CSS overrides that don't work with DaisyUI's architecture.
Current Problem
What Developers Try (Doesn't Work)
/* ❌ Traditional CSS approach - doesn't work with DaisyUI */
.btn.btn-primary {
background-color: #2563eb;
color: white;
}Why It Fails
DaisyUI uses CSS custom properties:
.btn {
background-color: var(--btn-bg);
color: var(--btn-fg);
}
.btn-primary {
--btn-color: var(--color-primary);
--btn-fg: var(--color-primary-content);
}Direct CSS properties don't override the CSS variable system effectively.
Impact on Developers
- Frustration: Developers spend hours trying to override button colors
- Workarounds: Resort to
!importanthacks or inline styles - Inconsistency: Different teams use different approaches
- Adoption Barriers: May choose other UI libraries due to perceived customization limitations
Proposed Solutions
1. Enhanced Documentation 📚
Add a dedicated section to the documentation:
"Customizing DaisyUI Component Colors"
## Customizing Button Colors
DaisyUI uses CSS custom properties for theming. To customize colors:
### ✅ Correct Approach
```css
@layer components {
.btn.btn-primary {
--btn-color: #2563eb;
--btn-fg: white;
}
.btn.btn-primary:hover {
--btn-color: #1d4ed8;
}
}❌ Common Mistake
/* This won't work reliably */
.btn.btn-primary {
background-color: #2563eb;
color: white;
}Theme-Level Customization
:root[data-theme="custom"] {
--color-primary: #2563eb;
--color-primary-content: white;
}
### 2. Code Examples & Recipes 🍳
Provide ready-to-use examples:
```typescript
// Example: Branded button theme
const brandedButtonTheme = `
.btn.btn-primary {
--btn-color: var(--brand-primary, #2563eb);
--btn-fg: var(--brand-primary-text, white);
}
`;
3. TypeScript Theme Interface 📝
interface DaisyUIButtonTheme {
primary: {
color: string;
foreground: string;
hover?: string;
};
success: {
color: string;
foreground: string;
hover?: string;
};
// ... other variants
}4. CSS Helper Utilities 🛠️
Consider providing optional utility classes:
/* Optional utilities for common customizations */
.btn-solid-blue { --btn-color: #2563eb; --btn-fg: white; }
.btn-solid-green { --btn-color: #16a34a; --btn-fg: white; }
.btn-solid-red { --btn-color: #dc2626; --btn-fg: white; }Examples That Should Be Documented
Corporate Branding
/* Company theme customization */
:root {
--color-primary: #1e40af;
--color-primary-content: white;
--color-secondary: #7c3aed;
--color-accent: #f59e0b;
}Per-Component Overrides
/* Specific component styling */
.dashboard .btn.btn-primary {
--btn-color: #059669;
--btn-fg: white;
}Dynamic Theming
// Runtime theme switching
document.documentElement.style.setProperty('--color-primary', newColor);Testing Checklist
Before closing this issue, the following should be verified:
- Documentation includes CSS custom property approach
- Examples show both theme-level and component-level customization
- Migration guide from traditional CSS to CSS variables
- TypeScript interfaces for theme configuration
- Examples work in both light and dark modes
- Accessibility considerations are documented
Additional Context
Environment
- Package: @etherisc/ui-kit v0.4.6
- DaisyUI: Integrated in distribution
- Issue Source: Real-world developer experience in production application
User Feedback
"We spent half a day trying to get white text on colored buttons. The documentation doesn't explain how DaisyUI's CSS variable system works."
Workaround Currently Used
/* Current workaround - not ideal */
.btn.btn-primary {
background-color: #2563eb !important;
color: white !important;
}Success Criteria
This issue is resolved when:
- A developer can customize button colors in under 10 minutes
- Documentation clearly explains the CSS custom property approach
- No
!importantdeclarations are needed for basic customization - Examples cover common use cases (branding, per-page themes, etc.)
Priority Justification
Medium Priority because:
- Affects developer adoption and productivity
- Leads to inconsistent implementations across teams
- Core functionality works, but DX is poor
- Relatively low effort to fix with high impact on user satisfaction
This issue was discovered during real-world application development and represents feedback from multiple developers attempting to customize ui-kit components.