Sign In

retroify.js

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

retroify.js

A library to apply retro 8-bit styling to web pages

latest
Source
npmnpm
Version
0.2.1
Version published
Maintainers
1
Created
Source

Retroify.js NPM Version License GitHub Copilot

Add instant retro 8-bit styling to any website with a single line of JavaScript. Retroify.js transforms your modern web elements into a nostalgic, pixelelated interface inspired by classic video games.

Features

  • 🎮 8-bit pixel-perfect styling
  • 🖼️ Pixelated image rendering
  • 📝 Retro typography using "Press Start 2P" font
  • 🔲 Pixel-perfect buttons and form elements
  • 📺 Optional CRT scanline effect
  • 🎨 Customizable shadow colors
  • ♿ Accessibility-friendly
  • 📱 Responsive design
  • 🔄 Easy to implement and remove
  • 🌐 Wide browser support

Installation

<script src="https://cdn.jsdelivr.net/npm/retroify.js/out/retroify.min.js"></script>

NPM

npm install retroify.js

Quick Start

  • Add the script to your HTML:
<script src="path/to/retroify.js"></script>
  • Apply retro styling to your entire page:
retroify.apply();

Or target specific elements:

retroify.apply('#game-container');

API Reference

Methods

retroify.apply([target])

Apply retro styling to the page or a specific element.

  • target (optional): CSS selector or HTMLElement
  • Returns: Retroify instance
// Apply to entire page
retroify.apply();

// Apply to specific element
retroify.apply('#game-section');

retroify.remove([target])

Remove retro styling.

  • target (optional): CSS selector or HTMLElement
  • Returns: Retroify instance
retroify.remove();

retroify.toggle()

Toggle retro styling and scanlines on/off.

  • Returns: Retroify instance
retroify.toggle();

retroify.toggleScanlines([enable])

Toggle CRT scanline effect.

  • enable (optional): Boolean to force state
  • Returns: Retroify instance
// Toggle scanlines
retroify.toggleScanlines();

// Force enable
retroify.toggleScanlines(true);

retroify.destroy()

Clean up and remove all Retroify modifications.

  • Returns: Retroify instance
retroify.destroy();

CSS Custom Properties

Customize the appearance using CSS variables:

.retroify {
  --retroify-shadow-color: 0 0 0;  /* RGB values for shadows */
  --retroify-shadow-opacity: 0.3;  /* Shadow opacity (0-1) */
}

Events

Retroify dispatches custom events:

  • retroify:applied - Fired when styles are applied
  • retroify:removed - Fired when styles are removed
window.addEventListener('retroify:applied', (e) => {
  console.log('Retroify applied to:', e.detail.target);
});

Examples

Basic Implementation

<!DOCTYPE html>
<html>
<head>
    <title>Retroify Example</title>
    <script src="path/to/retroify.js"></script>
</head>
<body>
    <div id="game">
        <h1>My Retro Game</h1>
        <button>Start Game</button>
    </div>
    
    <script>
        retroify.apply('#game');
    </script>
</body>
</html>

Interactive Toggle

const toggleButton = document.querySelector('#retro-toggle');
toggleButton.addEventListener('click', () => {
    retroify.toggle();
});

Browser Support

  • Chrome 49+
  • Firefox 44+
  • Safari 9.1+
  • Edge 16+
  • Opera 36+

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see the LICENSE file for details.

Keywords

css

FAQs

Package last updated on 15 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts