<hexchess-board>

Chess is better with hexagons

API

<hexchess-board>

A hexagonal chess board used for playing Glinsky-style hex chess. Player variables

Attributes

NameDescriptionTypeDefault
turn
board
moves
black-player-name
white-player-name
orientation
player-role
hide-coordinates
frozen
show-hints
hide-playernames
hide-capturedpieces
history-animation-duration
color-schemeForce `light`, `dark`, or `auto` (default) theming. When unset, the component follows the page/system preference.
mutedWhen present, disables all built-in sound effects.

Methods

NameParametersDescriptionReturn
requestUpdate
NameDescriptionType
_propertystring
void
exportExports the current game to a CSV list of moves that can be fed back into this same component.string
fenConverts to a hex-FEN notation describing the state of the board. Includes the positions of all the pieces along with whose turn it is.string
flipFlip the orientation of the board.void
resizeResize the board based on the latest dimensions given to the shadow root.void
rewindRewinds one move to a previous position. If there are no previous moves, this does nothing.void
rewindAllRewinds all moves until the starting position of the board is reached.void
fastForwardFast forwards one move to the next position. If there are no next moves, this does nothing.void
fastForwardAllFast forwards all moves until the current state of the board is reached.void
freezePrevent any more moves to the game. Usually called when the game is over.void
unfreezeUnfreeze the board and re-enable moves to be made.void
move
NameDescriptionType
fromstring
Make a move on the board.
move
NameDescriptionType
fromSquare
toSquare
boolean
move
NameDescriptionType
argstring | Square
toSquare
boolean
promote
NameDescriptionType
piecePiece
Promote a pawn.
resetResets and unfreezes the board to the default start state.void
prepareAudioPreloads the configured audio files and unlocks playback. Call this inside a user gesture handler if you need audio before any board interaction occurs.Promise
stopCustomEventsPauses all custom events from being emitted. This is useful when replaying many pre-programmed moves.void
restartCustomEventsvoid

Events

NameDescription
promotingFired when a pawn is ready to promote.
promotedFired when a pawn has been promoted to a piece.
gameoverFired when the game is over.
moveFired when a move is made on the board.
furthestbackFired when the game is rewound to its starting position.
furthestforwardFired when a game is fast forwarded back to its current position.

CSS Custom Properties

NameDescription
--hexchess-playername-sizeThe font size of the player names.
--hexchess-playername-colorThe color of the player names. Board variables
--hexchess-board-bgThe background color of the whitespace of the board (not tiles).
--hexchess-board-bg-lightLight mode override for the board background color.
--hexchess-board-bg-darkDark mode override for the board background color.
--hexchess-white-bgThe background color of the white tiles.
--hexchess-white-bg-lightLight mode override for the white tiles.
--hexchess-white-bg-darkDark mode override for the white tiles.
--hexchess-selected-white-bgThe background color of a white tile that's selected to be moved.
--hexchess-selected-white-bg-lightLight mode override for selected white tiles.
--hexchess-selected-white-bg-darkDark mode override for selected white tiles.
--hexchess-black-bgThe background color of the black tiles.
--hexchess-black-bg-lightLight mode override for the black tiles.
--hexchess-black-bg-darkDark mode override for the black tiles.
--hexchess-selected-black-bgThe background color of a black tile that's selected to be moved.
--hexchess-selected-black-bg-lightLight mode override for selected black tiles.
--hexchess-selected-black-bg-darkDark mode override for selected black tiles.
--hexchess-grey-bgThe background color of the grey tiles.
--hexchess-grey-bg-lightLight mode override for the grey tiles.
--hexchess-grey-bg-darkDark mode override for the grey tiles.
--hexchess-selected-grey-bgThe background color of a grey tile that's selected to be moved.
--hexchess-selected-grey-bg-lightLight mode override for selected grey tiles.
--hexchess-selected-grey-bg-darkDark mode override for selected grey tiles.
--hexchess-label-bgThe background color of the column and row labels.
--hexchess-label-bg-lightLight mode override for label color.
--hexchess-label-bg-darkDark mode override for label color.
--hexchess-label-sizeThe font size of the column and row labels.
--hexchess-possible-move-bgThe fill color of the small dot shown on a hexagon indicating this is a legal move.
--hexchess-possible-move-bg-lightLight mode override for the legal move dot.
--hexchess-possible-move-bg-darkDark mode override for the legal move dot.
--hexchess-possible-move-opponent-bgThe fill color of the small dot shown on a hexagon indicating this is a move an opponent piece can make.
--hexchess-possible-move-opponent-bg-lightLight mode override for the opponent move dot.
--hexchess-possible-move-opponent-bg-darkDark mode override for the opponent move dot.
--hexchess-possible-capture-bgThe stroke color of the large circle outlining a piece that can be captured.
--hexchess-possible-capture-bg-lightLight mode override for the capture ring color.
--hexchess-possible-capture-bg-darkDark mode override for the capture ring color.
--hexchess-possible-move-stroke-whiteThe outline color of a hexagon when the user drags over a white square, trying to move there.
--hexchess-possible-move-stroke-white-lightLight mode override for white square drag outlines.
--hexchess-possible-move-stroke-white-darkDark mode override for white square drag outlines.
--hexchess-possible-move-stroke-greyThe outline color of a hexagon when the user drags over a grey square, trying to move there.
--hexchess-possible-move-stroke-grey-lightLight mode override for grey square drag outlines.
--hexchess-possible-move-stroke-grey-darkDark mode override for grey square drag outlines.
--hexchess-possible-move-stroke-blackThe outline color of a hexagon when the user drags over a black square, trying to move there.
--hexchess-possible-move-stroke-black-lightLight mode override for black square drag outlines.
--hexchess-possible-move-stroke-black-darkDark mode override for black square drag outlines.
--hexchess-possible-move-stroke-opponentThe outline of a square when dragging an opponent piece to a possible move.
--hexchess-possible-move-stroke-opponent-lightLight mode override for opponent drag outlines.
--hexchess-possible-move-stroke-opponent-darkDark mode override for opponent drag outlines.