---
title: Play a game of chess
description: A local two-player chessboard with legal moves, promotion, and undo.
---

[@chess]: ./chess.components.md

# Your move

Play both sides or share the board with a friend. Select a piece to see its
legal moves, then select a highlighted square. White moves first.

<chess-game id="practice" mode="play" pieces="./assets/pieces/wood" />

Use **Undo** to take back a move or **Reset** to start again. On a keyboard,
Tab to the board, use the arrow keys to explore squares, and press Enter or
Space to select. Escape clears your selection.

Your game lives in this browser page; refreshing starts a new game.

## Add a board to a page

```md
[@chess]: ./chess.components.md

<chess-game id="practice" mode="play" pieces="./assets/pieces/wood" />
```

Give each board a unique `id`. Add a `fen` attribute to start from a specific
position, such as a puzzle or endgame.

[Study the Opera Game](./opera-game.demo.md) ·
[Read the component source](./chess.components.md)

<x-docs-source-link />
