Skip to content

Pixel Spinner

The PixelSpinner component displays a retro-style loading animation with a 4x4 grid of pixels that animate sequentially, perfect for gaming or retro-themed applications.

Basic Usage

jsx
import { PixelSpinner } from "fancy-react-ui";

function App() {
  return <PixelSpinner />;
}

Live Demo:

Props

Prop NameTypeDefaultDescription
sizenumber40Size in pixels
colorstring#2196f3Color of the pixels
textstringLoadingLoading text to display
speednumber1Animation speed in seconds
pixelSizenumber4Size of each pixel
classNamestring""Additional CSS class names
styleobject{}Additional inline styles

Examples

Basic Pixel Spinner

jsx
<PixelSpinner size={48} color="#2196F3" text="Loading" pixelSize={4} />

Custom Size and Color

jsx
<PixelSpinner size={60} color="#9933ff" />

Custom Text and Pixel Size

jsx
<PixelSpinner text="Please wait..." pixelSize={6} color="#ff3366" />

With Custom Styling

jsx
<PixelSpinner
  size={50}
  color="#33cc33"
  className="custom-pixel"
  style={{ margin: "20px" }}
/>

Implementation Details

The PixelSpinner consists of a 4x4 grid (16 pixels) that animate with sequential delays. Each pixel animates independently with a 0.1s delay from the previous pixel.

jsx
// Internal structure
<div className="pixel-spinner">
  <div className="pixel-grid">
    {/* 16 pixels with sequential delays */}
    {pixels.map((i) => (
      <div className="pixel" style={{ animationDelay: `${i * 0.1}s` }} />
    ))}
  </div>
  {text && <div className="pixel-text">{text}</div>}
</div>

Common Use Cases

Highlight typical scenarios where the spinner might be used:

  • Gaming applications
  • Retro-themed interfaces
  • 8-bit style websites
  • Game loading screens
  • Nostalgic user interfaces

Troubleshooting

Address potential issues developers might encounter, like:

  • Animation smoothness
  • Text alignment
  • Pixel sizing calculations
  • Browser compatibility
  • Performance optimization

Explore similar components within the same library or ecosystem to find the best fit for your use case:

Released under the MIT License.