Interactive hexagon grids with React bindings
> Note, I am not maintaining this library but happy to invite collaborators. Let me know!
!Downloads
!npm version
!dependencies Status

!License
React components to build interactive hexagon grids. This library uses SVG and allows you to create fully customizable and scalable interactive hexagon grids with a simple api.
The component based approach allows you to customize the grid shape to suit your needs or even apply your own components or SVG elements to it. You can use the pre-defined generator to create certain grid shapes or you may build your own grid as you wish, while still keeping it under control and interactive.
You could easily use this library to build a nice portfolio, image library or even a game (just to name a few)! , enjoy!
> With inspiration from
> http://www.redblobgames.com/grids/hexagons.
> 🖊️ Codepen to play around with: https://codepen.io/hellenic/project/editor/AYMbMM#
The new version should not contain any breaking changes. There is typescript support, some storybook examples for easy development and testing. The new version uses the newer react context api under the hood.
Though there should not be any breaking changes, there could be issues. Feel free to checkout the current beta release and give feedback.
Install via:
```
npm install react-hexgrid@beta
Install it via npm:
`shell`
npm install --save react-hexgrid
More documentation in the Wiki.
This hexagonal grid uses a cubic coordinate system with three coordinates q, r and s.
!cubic Coordinates. If you want to read about some hexagon mathematics and different coordinate systems maybe have a look at https://www.redblobgames.com/grids/hexagons/
`html
import { HexGrid, Layout, Hexagon, Text, Pattern, Path, Hex } from 'react-hexgrid';
import './App.css';
class App extends Component {
render() {
return (
Will look something like this (custom CSS applied):
!HexGrid image
Styling
There are many options on how to apply css styling. Examples of inline styling, classic css styling and css-in-js styling with emotion are shown in the storybook examples (under /src/stories/).
Drag and drop
There are examples of drag and drop implementations with native html5 drag and drop api, however these are not yet really well worked out. Feel free to jump in and maybe provide implementations with other drag and drop libraries.
Examples / Storybook
To run storybook run
npm i and then npm run storybook`. Other examples are available in the examples (standalone versions based on create react app).1. basic-board - Basic usage of react-hexgrid
2. custom-grid - Simple custom grid
3. templates - Ready-made grid templates
1. pathfinding - Pathfinding
2. drag & drop - Drag & drop with two grids
3. animations - Animations & effects
You can test changes locally by running storybook. You can also use something like npm 7 workspaces to link this library on your local file system side by side with your application.
MIT