The premier Angular wrapper for the world-class open-source chess UI library.
If you are a chess lover and find this project useful, please consider sponsoring it to support further development!
Your support helps me maintain the library, add new features, and keep the application up-to-date with the latest Angular and Chessground releases.
โจ Sponsor Perk: Sponsors can request to have their favorite or "evergreen" chess game permanently added to the demo application's built-in game list!
How to add your game:
- Sponsor the project via GitHub Sponsors.
- Submit a Pull Request (PR) to this repository.
- In your PR, include the PGN file, brief game details, and your Sponsor Name.
- ๐งฉ Standalone Components:
NgxChessgroundComponent,NgxChessgroundTableComponent,NgxPgnViewerComponentโ all standalone, import-ready. - โก Full chessground API Access: The
runFunctioninput gives you direct access to the chessgroundApifor complete control over board state, moves, animations, and events. - ๐ฆ Pre-built Unit Presets:
initial,castling,playVsRandom,playFullRandom,slowAnim, and more โ pre-configured board setups ready to drop in. - ๐ง Utility Functions: Exported helpers โ
toDests(),toColor(),playOtherSide(),aiPlay()โ for building custom chess UIs. - ๐จ Promotion Dialog: Built-in Material dialog for pawn promotion selection with queen/rook/bishop/knight options.
- ๐ Modern Angular: Standalone components, signal-based inputs, compatible with Angular 21 out of the box.
- ๐ Comprehensive PGN Viewer: Load and navigate through complex chess games effortlessly.
- โช Game Replay Options:
- Step-by-step manual replay.
- Real-time replay (watch exactly as the game was played).
- Proportional replay (fit to one minute or predefined speeds).
- Customizable minimum time delay between moves.
- ๐ Advanced Filtering:
- Filter by ECO codes, player names, and time controls.
- Dynamically filter games by playing the specific starting opening moves on the board!
- Include or exclude drawn games instantly.
- ๐ค Stockfish Integration ("Stop on error"):
- Background game analysis via Stockfish web worker.
- Auto-halts replays when a blunder or significant error occurs.
- Instantly reveals Stockfish's suggested best move and Principal Variation (PV) lines.
- ๐ก ECO Moves Tooltips: Hover over ECO codes to see the exact opening move sequence.
- ๐ญ Play Against Yourself: A specialized mode for analyzing positions or practicing openings like Robert James Fischer.
- ๐ฑ Mobile-Ready: Responsive design with interactive elements tailored for all devices.
- ๐ฅ Progressive Web App (PWA): Installable as a standalone app directly on your device.
The demo application (ngx-chessground-example) is a powerful tool for exploring chess games and features. Here are a few guides to get you started:
๐ฑ Install as SPA (PWA)
- Open the live demo in a supported browser (e.g., Chrome, Edge, Safari).
- Look for the "Install" icon in the address bar (or in your browser's menu options: "Install App" or "Add to Home Screen").
- Click Install and the application will be available on your desktop/home screen, working offline where applicable.
โ๏ธ Filter by Starting Opening Moves
- Load a PGN file containing multiple games.
- In the "Filter by Starting Moves" section, check the enable box.
- Use the board to play the specific opening moves you want to filter by (e.g.,
1. e4 e5). - Click the "Filter" button. The application will instantly list only the games matching that exact opening sequence.
๐ค Use "Stop on error" (Stockfish Integration)
- Load a game into the PGN Viewer.
- Toggle the "Stop on error" checkbox.
- Start the auto-replay.
- The application analyzes the game utilizing the built-in Stockfish web worker. If a significant mistake is detected, the replay will automatically halt.
- The UI will display Stockfish's suggested best move and the optimal continuation line (PV), allowing you to study the critical moment.
This repository contains two robust projects:
- ๐ฆ ngx-chessground - The core Angular library.
- ๐น๏ธ ngx-chessground-example - The fully-featured demo application and PGN viewer.
Install the library in your Angular project via npm:
npm install ngx-chessground chess.js chessground snabbdomClone and set up the development environment quickly:
git clone https://github.com/topce/ngx-chessground.git
cd ngx-chessground
npm install
npm startAll components are standalone โ import them directly.
import { Component, signal } from '@angular/core';
import { NgxChessgroundComponent } from 'ngx-chessground';
import { Chessground } from 'chessground';
import type { Api } from 'chessground/api';
@Component({
selector: 'app-board',
standalone: true,
imports: [NgxChessgroundComponent],
template: `<ngx-chessground [runFunction]="myFn()" />`
})
export class BoardComponent {
groundApi = signal<Api | null>(null);
myFn = signal<(el: HTMLElement) => Api>((el) => {
const api = Chessground(el, {
fen: 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1',
orientation: 'white',
movable: { free: true, color: 'both' }
});
this.groundApi.set(api);
return api;
});
}The runFunction input receives the mounted DOM element and returns a chessground Api instance โ giving you full control over board configuration.
For PGN viewing, use the pre-built viewer component:
<ngx-pgn-viewer
[pgn]="pgnString"
[highlightLastMove]="true"
/>See the library README for comprehensive API documentation covering all components, services, unit presets, and utility functions.
Comprehensive API documentation is available in the library README.
To generate and view detailed Compodoc documentation locally:
npm run compodocThe documentation server will start at http://localhost:9090
| NgxChessground | Angular Framework |
|---|---|
| 21.x | 21.x |
| 20.x | 20.x |
| 19.x | 19.x |
| 18.x | 18.x |
| 17.x | 17.x |
| 16.x | 16.x |
| 15.x | 15.x |
Contributions, issues, and feature requests are welcome! Feel free to check out the issues page or submit a Pull Request.
Released under the GPL-3.0 License (or later).
- Stockfish โ The bundled engine is copyright ยฉ T. Romstad, M. Costalba, J. Kiiski, G. Linscott and contributors. GPLv3.
- stockfish.js โ JS/WebAssembly build by nmrugg (ยฉ Chess.com, LLC). GPLv3.
- chessground โ Chess board UI by Thibault Duplessis (ornicar). GPL-3.0-or-later.
- chess.js โ Chess rules and move validation by Jeff Hlywa. BSD-2-Clause.
- chessops โ Chess operations library by Niklas Fiekas. GPL-3.0-or-later.
- snabbdom โ Virtual DOM used by chessground, by Simon Friis Vindum. MIT.
- fzstd โ Zstandard decompression for compressed PGN, by Arjun Barrett. MIT.
- jszip โ ZIP archive support for PGN files, by Stuart Knightley. MIT / GPL-3.0-or-later.