npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@hemicycle/react

v0.1.5

Published

Core Hemicycle layout computations

Downloads

576

Readme

@hemicycle/react

npm version License: MIT Node.js >=18

React component for rendering parliament-style hemicycle seat charts.

@hemicycle/react is the React wrapper around @hemicycle/vanilla. Drop in a <Hemicycle> component, pass your seat data as props, and get a fully rendered SVG chart that re-renders reactively on changes.


Features

  • Single <Hemicycle> component — configure layout and data entirely through props
  • Per-seat React wrappers — wrap any seat with a custom React node (tooltips, popovers, links, etc.)
  • Per-seat SVG props — attach onClick, aria-*, data-*, and any other SVG attributes to individual seats
  • All @hemicycle/vanilla options — shapes (arc, rect, circle), aisles, mirroring, radii, and more
  • TypeScript generics — type your seat data end-to-end with HemicycleProps<T>

Installation

npm install @hemicycle/react

Requires React ≥ 18 and Node.js ≥ 18.


Quick Start

import { Hemicycle } from "@hemicycle/react";

export function ParliamentChart() {
  return (
    <Hemicycle
      rows={7}
      totalSeats={577}
      innerRadius={40}
      outerRadius={95}
      width={800}
      height={420}
    />
  );
}

API

<Hemicycle>

All props are optional. Accepts all @hemicycle/vanilla config options plus:

| Prop | Type | Description | | ------------ | ------------------------------- | ------------------------------------------------- | | data | HemicycleData<T>[] | Seat data array (see below) | | svgProps | React.SVGProps<SVGSVGElement> | Extra props forwarded to the root <svg> element | | seatConfig | SeatConfig<T> | Default visual style and behavior for all seats |

SeatConfig<T>

Extends the vanilla SeatConfig (shape, color, borderRadius, radius) with two React-specific additions:

| Option | Type | Description | | --------- | -------------------------------- | ------------------------------------------------- | | wrapper | (content, data) => ReactNode | Wraps each seat's <path> in a custom React node | | props | React.SVGProps<SVGPathElement> | Default SVG props applied to every seat <path> |


Seat data

Each item in the data array identifies a seat by index or by coordinates, exactly as in @hemicycle/core, and may include a per-seat seatConfig to override styles and behavior for that seat:

type HemicycleData<T> = T &
  ({ idx: number } | { rowIndex: number; seatIndex: number }) & {
    seatConfig?: SeatConfig<T>;
  };

Per-seat seatConfig is merged on top of the global seatConfig prop, so you only need to specify what differs.


Examples

Coloring seats by party

const members = [
  { idx: 0, party: "Left", color: "#e63946" },
  { idx: 1, party: "Center", color: "#457b9d" },
  // ...
];

<Hemicycle
  rows={7}
  totalSeats={577}
  data={members.map((m) => ({
    idx: m.idx,
    party: m.party,
    seatConfig: { color: m.color },
  }))}
/>;

Clickable seats with tooltips

<Hemicycle
  rows={5}
  totalSeats={100}
  data={seats.map((seat) => ({
    idx: seat.idx,
    seatConfig: {
      color: seat.partyColor,
      props: {
        onClick: () => setSelected(seat),
        style: { cursor: "pointer" },
      },
      wrapper: (content, data) => (
        <Tooltip key={data?.idx} label={data?.party}>
          {content}
        </Tooltip>
      ),
    },
  }))}
/>

Custom SVG container props

<Hemicycle
  rows={5}
  totalSeats={100}
  svgProps={{
    className: "my-chart",
    "aria-label": "Parliament seating chart",
    style: { maxWidth: "100%" },
  }}
/>

Typed seat data

type Member = {
  name: string;
  party: string;
};

const data: HemicycleData<Member>[] = members.map((m) => ({
  idx: m.seatNumber,
  name: m.name,
  party: m.party,
  seatConfig: { color: m.partyColor },
}));

<Hemicycle<Member> data={data} rows={7} totalSeats={577} />;

Seat Shapes

| Shape | Description | | -------- | ---------------------------------------------------------------- | | arc | Curved wedge following the concentric arc of the row (default) | | rect | Rectangle aligned to the seat's arc midpoint | | circle | Circle centered at the seat's midpoint |


Related


Contributing

Bug reports and pull requests are welcome on GitHub.


Support


Maintainer

Gabriel Vidal[email protected]


License

MIT