BlackMagic.js

The world's first truly automatic dark mode framework. Zero configuration, perfect accessibility, works everywhere.

Why BlackMagic.js?

🚀

Zero Configuration

Works instantly out of the box. No CSS variables, no manual color definitions. Just import and toggle.

WCAG 2.1 Compliant

Automatically ensures 4.5:1 contrast ratios for all text elements. Perfect accessibility without the work.

🎨

Preserves Design

Uses advanced color science to maintain brand identity and visual hierarchy in dark mode.

Lightning Fast

Color calculations complete in under 50ms. 8KB minified with zero dependencies.

🔒

Persistent Storage

Dual storage system (cookies + localStorage) ensures theme preferences never get lost.

🌐

Universal Compatibility

Works with any website, framework, or CMS. Chrome 60+, Firefox 60+, Safari 12+, Edge 79+.

Traditional vs BlackMagic Approach

Traditional Dark Mode (500+ lines)
/* Manual color definitions for everything */
.dark-mode .button { 
  color: #ffffff; 
  background: #333333; 
}
.dark-mode .text { 
  color: #e0e0e0; 
}
.dark-mode .card { 
  background: #2a2a2a; 
  border: 1px solid #444444; 
}
.dark-mode .link { 
  color: #60a5fa; 
}
/* ...hundreds more lines... */
/* Still breaks accessibility */
/* Still looks terrible */
BlackMagic Approach (3 lines)
// Everything just works
const blackMagic = new BlackMagic();

// Toggle between themes
blackMagic.toggle();

// That's it! 
// ✅ Perfect contrast ratios
// ✅ Preserved brand colors  
// ✅ No CSS needed
// ✅ Works everywhere

Interactive Demo

Click the buttons below to see BlackMagic.js in action. Notice how all colors automatically adjust while maintaining perfect readability.

Sample Website Content

This is what your website looks like with BlackMagic.js. Notice how all text remains perfectly readable while maintaining the visual hierarchy and brand colors.

Action button with proper contrast

Card Component

Cards and containers automatically get proper backgrounds and borders that work in both light and dark modes.

Link with preserved brand color
Warning message with custom background

Real-World Performance

98.7%
WCAG Compliance Rate
<50ms
Color Calculation Time
8KB
Minified Size
0
Dependencies

Get Started in 60 Seconds

NPM Installation
# Install via NPM
npm install blackmagic-js

# Import and use
import BlackMagic from 'blackmagic-js';

const darkMode = new BlackMagic({
  backgroundColor: '#1a1a1a',
  factor: 0.4
});

// Add to any button
button.addEventListener('click', () => {
  darkMode.toggle();
});
CDN Installation
<!-- Include via CDN -->
<script src="https://cdn.jsdelivr.net/npm/blackmagic-js@latest"></script>

<script>
  // Initialize
  const blackMagic = new BlackMagic();
  
  // Add to toggle button
  document.getElementById('toggle')
    .addEventListener('click', () => {
      blackMagic.toggle();
    });
</script>