Pixel Icon

Pixel Icon

July 2024

Customizable and interactive pixel-based icons

Loading...

Installation

pnpm dlx @bucharitesh/cli@latest add 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 :)