TFT

Dark Mode CSS Generator

Generate CSS for dark mode support using prefers-color-scheme and manual toggle. Create theme-aware stylesheets.

Light Mode Colors
Dark Mode Colors
Options
Quick Presets
Preview

Light Mode Preview

Background: #ffffff | Text: #1f2937

Dark Mode Preview

Background: #1f2937 | Text: #f9fafb

Generated CSS
/* CSS Custom Properties for theming */
:root {
  --bg-primary: #ffffff;
  --text-primary: #1f2937;
  --color-primary: #6366f1;
}

/* Dark mode overrides */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #1f2937;
    --text-primary: #f9fafb;
  }
}

/* Manual dark mode class */
.dark {
  --bg-primary: #1f2937;
    --text-primary: #f9fafb;
}

/* Base styles using variables */
body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color 300ms ease, color 300ms ease;
}

/* Example component */
.card {
  background-color: var(--bg-primary);
  border: 1px solid var(--text-primary);
  opacity: 0.1;
}

/* Links */
a {
  color: var(--color-primary);
}

/* Smooth transitions for theme switching */
* {
  transition: background-color 300ms ease,
    color 300ms ease,
    border-color 300ms ease;
}
JavaScript Toggle
// JavaScript for manual dark mode toggle
function toggleDarkMode() {
  document.documentElement.classList.toggle('dark');
  
  // Save preference
  const isDark = document.documentElement.classList.contains('dark');
  localStorage.setItem('darkMode', isDark);
}

// Check saved preference
const savedDarkMode = localStorage.getItem('darkMode');
if (savedDarkMode === 'true') {
  document.documentElement.classList.add('dark');
}

// Check system preference
if (!savedDarkMode && window.matchMedia('(prefers-color-scheme: dark)').matches) {
  document.documentElement.classList.add('dark');
}

About Dark Mode

Dark mode has become an expected feature in modern websites and applications. It reduces eye strain in low-light conditions, saves battery on OLED screens, and provides users with choice over their viewing experience.

CSS dark mode can be implemented using the prefers-color-scheme media query for automatic system-based switching, or with CSS custom properties and JavaScript for manual toggle functionality.

Implementation Approaches

System Preference
Uses @media (prefers-color-scheme: dark) to automatically match the user's system settings. No JavaScript required, respects user's OS-level preference.
Manual Toggle
Uses a .dark class on the document root with JavaScript toggle. Gives users explicit control and can persist preference across sessions.

Dark Mode Tips

  • Don't use pure black: Use dark gray (#1f2937) to reduce eye strain
  • Adjust contrast: Dark mode needs different contrast ratios than light mode
  • Test colors: Some colors that look good in light mode may vibrate in dark mode
  • Smooth transitions: Add transitions for pleasant theme switching
  • Save preference: Use localStorage to remember user's choice

Other Free Tools

CSS Gradient Generator

Create linear, radial, and conic gradients with live preview. Generate CSS gradient code for backgrounds and UI. Free online gradient maker.

CSS Mesh Gradient Generator

Create stunning multi-point mesh gradients with smooth color transitions. Generate CSS and SVG mesh gradients. Free online mesh gradient tool.

Glassmorphism Generator

Create glassmorphism effects with backdrop-filter, blur, and transparency. Generate modern frosted glass CSS. Free online glassmorphism generator.

Neumorphism Generator

Create soft UI neumorphic effects with subtle shadows and highlights. Generate modern soft design CSS. Free online neumorphism generator.

CSS Border Radius Generator

Create asymmetric border-radius values with live preview. Generate organic, smooth corner shapes for modern UI design. Free online border radius tool.

CSS Box Shadow Generator

Create multi-layer box shadows with blur, spread, and inset options. Generate beautiful shadows for buttons, cards, and UI elements. Free online CSS shadow tool.

CSS Button Generator

Design beautiful buttons with hover effects, gradients, and shadows. Generate production-ready CSS button styles. Free online CSS button maker.

CSS Filter Generator

Apply blur, brightness, contrast, hue-rotate, and more filters visually. Generate CSS filter code instantly. Free online CSS filter generator.

CSS Color Converter

Convert colors between HEX, RGB, HSL, HSV, OKLCH, and more. Get CSS-ready color values instantly. Free online CSS color converter for designers and developers.

CSS Color Palette Generator

Generate harmonious color palettes from images or color theory rules. Export CSS variables and Tailwind config. Free online color palette generator for web design.

Tint & Shade Generator

Generate tints (lighter) and shades (darker) of any color across multiple steps. Build color scales for design systems. Free online tint shade tool.

CSS Pattern Generator

Generate repeating patterns — stripes, dots, checkerboard, waves — using CSS and SVG. Free online CSS pattern generator for backgrounds.

CSS Background Noise Generator

Generate subtle noise and grain textures using CSS and SVG filters. Add depth and texture to backgrounds with this free online CSS noise generator.

CSS Text Shadow Generator

Create multi-layer text shadows with blur, spread, and color. Generate beautiful text effects. Free online CSS text shadow generator.

CSS Shape Generator

Create triangles, arrows, speech bubbles, and more using pure CSS. Generate shape code instantly. Free online CSS shape maker.

CSS Clip Path Maker

Draw custom clip-path shapes — polygons, circles, ellipses — with visual editor. Generate CSS clip-path code instantly. Free online clip path generator.

CSS Transition Previewer

Preview and compare CSS transition easing functions. Test built-in and custom cubic-bezier curves. Free online transition previewer.

Cubic Bezier Editor

Visually create custom cubic-bezier easing functions. Generate smooth, natural animations. Free online cubic-bezier editor for CSS transitions.

CSS Animation Generator

Create CSS keyframe animations with live preview. Generate smooth, performant animations for web projects with customizable easing, duration, and iteration. Free online CSS animation builder.

CSS Loader Generator

Create pure CSS loading spinners, dots, and bars. Customize size, color, and animation speed. Free online CSS loader generator.

CSS Grid Generator

Create CSS Grid layouts visually. Generate grid-template-areas, gap, and responsive breakpoints. Free online CSS Grid layout builder.

Flexbox Playground

Experiment with Flexbox properties interactively. Generate flex container and item CSS with live preview. Free online Flexbox learning tool.

CSS Spacing Scale Generator

Generate consistent spacing and size scales for design tokens. Create 4px, 8px, 16px base scales. Free online spacing scale generator.

Fluid Space Calculator

Generate clamp()-based responsive spacing that scales with viewport. Create fluid design systems. Free online fluid space calculator.

Fluid Typography Calculator

Create responsive font sizes using CSS clamp() for smooth scaling between breakpoints. Free online fluid typography generator.

PX to REM Converter

Convert pixels to REM and EM units with configurable root font size. Generate accessible, scalable CSS. Free online px to rem converter.

Viewport Unit Converter

Convert between vw, vh, vmin, vmax, and px units. Generate responsive viewport-based CSS. Free online viewport unit converter.

CSS calc() Builder

Build complex CSS calc() expressions visually. Create responsive calculations for widths, heights, margins, and more. Free online CSS calc builder.

Media Query Builder

Generate responsive CSS media queries visually. Pick breakpoints for mobile, tablet, and desktop. Free online media query generator.

Scroll Snap Builder

Configure CSS scroll-snap properties for smooth scrolling sections. Generate scroll-snap-type and alignment code. Free online scroll snap generator.