Styling Basics
Evidence uses:- Tailwind CSS - Utility-first CSS framework
- Custom CSS - Your own styles in
src/app.css - Component Props - Built-in styling options on components
- Themes - Light and dark mode support
Quick Styling with Component Props
Many components accept styling props:Chart Colors
Chart Sizing
BigValue Styling
Custom CSS
Edit app.css
Your global styles live in
src/app.css. This file is automatically loaded on every page.src/app.css
Real Example: Custom Styling
Here’s the styling from the Evidence example project:src/app.css
Tailwind Configuration
Customize Tailwind intailwind.config.cjs:
tailwind.config.cjs
Themes and Dark Mode
Evidence supports light and dark themes:src/app.css
CSS Variables
Define reusable values:src/app.css
Layout Customization
Customize your app’s layout insrc/pages/+layout.svelte:
src/pages/+layout.svelte
Component-Specific Styling
Tables
Lists
Code Blocks
Print Styles
Optimize for printing:src/app.css
Advanced: Custom Components
Create reusable styled components:src/components/StyledCard.svelte:
Best Practices
Organization
- Use layers - Keep Tailwind utilities separate from custom CSS
- Component-based - Create reusable styled components
- Variables - Use CSS variables for consistency
- Mobile-first - Design for mobile, enhance for desktop
Performance
- Minimize custom CSS - Prefer Tailwind utilities when possible
- Optimize fonts - Subset custom fonts to include only needed characters
- Remove unused styles - Tailwind’s purge removes unused classes
Consistency
- Design system - Define colors, spacing, and typography once
- Naming conventions - Use clear, descriptive class names
- Documentation - Comment complex styling decisions
Troubleshooting
Styles Not Applying
Check specificity: Evidence’s default styles may override yours. Use!important sparingly:
Tailwind Classes Not Working
Content paths: Ensuretailwind.config.cjs includes all file types:
Dark Mode Issues
Test both themes:Next Steps
- Component documentation - Learn about all available components
- Deployment - Deploy your styled app
- Examples - See styled apps in action