Skip to content

Pacman Spinner

The PacmanSpinner component displays a loading animation inspired by Pac-Man, featuring a chomping animation with dots being eaten.

Basic Usage

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

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

Live Demo:

Props

Prop NameTypeDefaultDescription
sizenumber40Size in pixels
colorstring#FFEB3BColor of Pacman and dots
speednumber1Animation speed in seconds
dotCountnumber4Number of dots
dotSizenumber6Size of dots in pixels
classNamestring""Additional CSS class names
styleobject{}Additional inline styles

Examples

Basic Pacman Spinner

jsx
<PacmanSpinner size={48} color="#FFEB3B" speed={1} dotCount={4} />

Custom Size and Color

jsx
<PacmanSpinner size={60} color="#FFC107" />

Custom Dots Configuration

jsx
<PacmanSpinner dotCount={5} dotSize={8} color="#FFD700" />

With Custom Styling

jsx
<PacmanSpinner
  size={50}
  color="#FFB300"
  className="custom-pacman"
  style={{ margin: "20px" }}
/>

Implementation Details

The PacmanSpinner consists of a Pacman character created with CSS shapes and animated dots that get "eaten".

jsx
// Internal structure
<div className="pacman-spinner">
  <div className="pacman">
    <div className="pacman-top" style={{ backgroundColor: color }} />
    <div className="pacman-bottom" style={{ backgroundColor: color }} />
  </div>
  <div className="dots">
    {[...Array(dotCount)].map((_, i) => (
      <div
        className="dot"
        style={{
          backgroundColor: color,
          animationDelay: `${(i * speed) / dotCount}s`,
        }}
      />
    ))}
  </div>
</div>

Common Use Cases

Highlight typical scenarios where the spinner might be used:

  • Gaming applications
  • Fun loading states
  • Interactive interfaces
  • Game loading screens
  • Playful web applications

Troubleshooting

Address potential issues developers might encounter, like:

  • Animation timing
  • Dot positioning
  • Shape rendering
  • 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.