Overview
Ficha Dubai includes a built-in dark mode toggle that allows users to switch between light and dark color schemes. The implementation uses Tailwind CSS’s dark mode utilities with class-based switching.HTML Implementation
The dark mode is enabled at the document root level:index.html:2
The
class="light" attribute on the <html> element is the default. Changing it to class="dark" activates dark mode throughout the entire application.Tailwind Configuration
Dark mode is configured to use class-based switching:index.html:11-34
With
darkMode: "class", Tailwind applies dark mode styles when the dark class is present on the root <html> element.Toggle Button
A floating toggle button is positioned in the bottom-left corner:index.html:238-241
Toggle Functionality
The toggle works via inline JavaScript:- Targets the root
<html>element (document.documentElement) - Toggles the
darkclass on/off - Triggers Tailwind’s dark mode styles instantly
Dark Mode CSS Classes
Throughout the HTML, elements use Tailwind’sdark: variant for dark mode styling:
Background Colors
index.html:70
Card Components
index.html:100
Text Colors
index.html:146
Borders
index.html:141
Thumbnails
app.js:300
Custom CSS Dark Mode
Thestyles.css file uses a glass card effect that adapts to dark mode:
index.html:48-56
Color Scheme
Light Mode Colors
| Element | Color | Hex Code |
|---|---|---|
| Background | Background Light | #f8fafc |
| Surface | White | #ffffff |
| Text | Slate 900 | #0f172a |
| Muted Text | Slate 600 | #475569 |
| Border | Slate 100 | #f1f5f9 |
Dark Mode Colors
| Element | Color | Hex Code |
|---|---|---|
| Background | Background Dark | #0f172a |
| Surface | Slate 800 | #1e293b |
| Text | Slate 100 | #f1f5f9 |
| Muted Text | Slate 400 | #94a3b8 |
| Border | Slate 700 | #334155 |
Transition Effects
Smooth color transitions are applied to the body element:index.html:70
This creates a smooth 300ms fade between light and dark themes.
Component Examples
Gallery Card
Description Section
Feature Badges
app.js:467
Effect: Subtle background and border adjustments for readability
Toggle Button Styling
Light Mode Button
White background, light border, displays moon icon
Dark Mode Button
Slate-800 background, dark border, displays sun icon
Position
Fixed bottom-left corner with 6-unit margin
Z-Index
z-50 ensures button stays above all other content
Persistence
Adding Persistence
To save user preference, add this JavaScript:Browser Support
| Feature | Support |
|---|---|
| CSS Dark Mode | All modern browsers |
| classList.toggle | IE10+ |
| Tailwind Dark Mode | All browsers supporting CSS custom properties |
| Material Icons | All browsers with web font support |
Accessibility
Respects System Preference (Optional)
Respects System Preference (Optional)
You can configure Tailwind to automatically follow system dark mode preference with
darkMode: "media" instead of "class".WCAG Contrast Ratios
WCAG Contrast Ratios
Ensure all text maintains sufficient contrast in both light and dark modes.
Button Accessibility
Button Accessibility
Related Features
- Responsive Design - Mobile-first approach
- Image Gallery - Gallery components with dark mode
- Lightbox - Dark overlay for full-screen viewing