Back to components
ComponentWidgetFree

Space Invaders Game React component

A canvas Space Invaders, a descending grid of pixel-drawn invaders that shoot back, three difficulty levels, keyboard controls on desktop and on-screen move/fire buttons on mobile, with a win/lose end screen.

About the Space Invaders Game component

Space Invaders Game is a shoot 'em up drawn on a canvas, with the invaders lined up to spell 404. You steer a ship along the bottom with the left and right arrow keys and fire with Space; holding Space fires a short burst and then pauses briefly. The invaders fire back at random, one hit ends the game, and clearing every invader wins it. Each invader destroyed is a point.

Players pick Easy, Medium or Hard, which change how often the invaders fire and how fast your ship and shots move, and Restart deals a fresh board. The wave waits for your first key press, so it never plays itself to a loss before anyone has touched it. On touch screens left, right and fire buttons appear under the board. The canvas fits the container width and is sharp on high-density screens, and lightMode switches to a light board.

When to use it

Use it on a 404 page, where the invaders spell out the error, or on a developer or gaming portfolio as a popup game.

For a runner with a single control, use Dino Runner Game. For a slower puzzle, use Minesweeper Game.

Installation

Add the Space Invaders Game component to your project with the shadcn CLI. It lands in components/space-invaders-game.tsx as plain React + Tailwind CSS source you own and can edit.

Install
Copied!
npx shadcn@latest add @reactframe/space-invaders-game

Or copy the source by hand and install its dependencies:

Install
Copied!
npm install clsx tailwind-merge

More Widget components

Glow Jump Widget
Free
Dino Runner Game
Free
Spin to Win Wheel
Free
Pong Game
Free
Memory Cards Widget
Free
Memory Match Game
Free