Craft
Pixel Icon

Pixel Icon

Customizable and interactive pixel-based icons

The Icon component creates customizable, interactive pixel-based icons. It supports hover effects, color changes, and pixel shape customization.

Installation

npx shadcn@latest add "https://bucharitesh.in/r/pixel-icon"

Props

PropTypeDescriptionDefault
iconnumber[][]2D array representing the icon's pixel layout
baseColorstringBase color of the icon
flickerColorstringColor used for the flicker effect
secondaryColorstringSecondary color for additional details"gray"
sizenumberSize of the icon in pixels80
flickerChancenumberProbability of pixel color change on hover (0 to 1)0.3
pixelShape"circle" | "square"Shape of individual pixels"circle"
classNamestringAdditional CSS classes for the icon container

Usage

import PixelIcon from "./PixelIcon";
 
const MyComponent = () => {
  const iconData = [
    [1, 1, 1],
    [1, 0, 1],
    [1, 1, 1],
  ];
 
  return (
    <PixelIcon
      icon={iconData}
      baseColor="#ff0000"
      flickerColor="#ffff00"
      secondaryColor="#0000ff"
      size={100}
      flickerChance={0.5}
      pixelShape="square"
    />
  );
};

Credits

  • Credit to @rauno for this beautiful blog :)