Theme Switching
Simple Charts supports both light and dark themes with automatic preference detection.How Theming Works
The theme system uses:- CSS custom properties: Defined in
src/index.css - Tailwind dark mode: Configured with class-based dark mode
- localStorage: Persists user preference
Theme Implementation
Fromsrc/hooks/useTheme.js:
Light Theme Variables
Fromsrc/index.css:
Dark Theme Variables
Theme preferences are automatically saved to
localStorage and restored on page reload.Color Palettes
Simple Charts includes 6 curated color palettes designed for educational use.Available Palettes
Fromsrc/constants/palettes.js:
Palette Usage
Colors are applied cyclically to chart items:Advanced Color Customization
The Advanced Colors section in ChartControlsPanel allows per-item color customization.Enable Custom Colors
Fromsrc/components/ChartControlsPanel.jsx:
Color Swatch Picker
When advanced colors are enabled, each data row gets a color picker with 16 preset swatches:Full Color Picker
Enable the full HTML color picker for unlimited color options:Advanced Swatches
The advanced color swatches are compiled from all palette colors:Reset Custom Colors
Users can reset all custom colors back to the selected palette:Custom Color Storage
Custom colors are stored in the app state and persisted tolocalStorage:
Tailwind Configuration
Simple Charts uses Tailwind with custom color variables:bg-primary, text-foreground, etc. to automatically adapt to the current theme.
Example: Creating a Custom Palette
To add a new color palette, editsrc/constants/palettes.js:
After modifying palettes, run
npm run build to rebuild the application.