# Seat map

> Pick seats while other people are picking too: yours rise with your initials, and a seat taken under you turns over with a ripple and points to the next best.

Seat pickers are a static grid that only learns a seat went at checkout. Seat map stays live. Tap a seat and it rises a little as your initials drop into it, while the seat list and the total roll. When someone else takes a seat while you look, it turns over to taken and a ripple runs out from it through the seats around, so your eye catches where it went. If it was one of yours, it shakes, lets go of your initials, and the nearest free seats in the same tier pulse as the next best. Past the most seats one person can hold, the count shakes instead of a dialog. Seats come from you: rows of seats with an aisle wherever you leave a gap, tiers with prices, and status that changes as your server says; the map tells you what’s picked and calls onContinue. Arrow keys move between seats, and narrow screens pack the seats tighter rather than scrolling.

## Install

```bash
npx shadcn@latest add https://hairlineui.com/r/seat-map.json
```

Needs React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.

- npm: none
- Hairline UI components it needs (the CLI installs them too): `number-roll`, `text-morph`
- Docs and live preview: https://hairlineui.com/ui/seat-map
- Registry item (source): https://hairlineui.com/r/seat-map.json

## Usage

```tsx
import { SeatMap } from "@/components/seat-map";

<SeatMap
  rows={rows}
  tiers={[{ id: "standard", name: "Standard", price: 14 }, { id: "premium", name: "Recliner", price: 21 }]}
  selected={mine}
  onSelectedChange={setMine}
  initials="MO"
  onContinue={(ids) => router.push(`/checkout?seats=${ids.join(",")}`)}
/>
```

## Live from your server

Poll or subscribe to the showing’s seats and pass them in; holds you place on your server keep the seats yours.

```tsx
"use client";
import * as React from "react";
import useSWR from "swr";
import { SeatMap, type SeatRow } from "@/components/seat-map";

export function Seats({ showingId }: { showingId: string }) {
  const { data } = useSWR<{ rows: SeatRow[] }>(`/api/showings/${showingId}/seats`, (u: string) => fetch(u).then((r) => r.json()), { refreshInterval: 2000 });
  const [mine, setMine] = React.useState<string[]>([]);
  return (
    <SeatMap
      rows={data?.rows ?? []}
      tiers={[{ id: "standard", name: "Standard", price: 14 }, { id: "premium", name: "Recliner", price: 21 }]}
      selected={mine}
      onSelectedChange={(ids) => {
        setMine(ids);
        fetch(`/api/showings/${showingId}/hold`, { method: "PUT", body: JSON.stringify({ seats: ids }) });
      }}
      onContinue={(ids) => (location.href = `/checkout?showing=${showingId}&seats=${ids.join(",")}`)}
    />
  );
}
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `rows` | `SeatRow[]` | – | Each row: id (its letter) and seats, left to right; a seat is { id, label, status: "free" \| "taken", tier? }, and null leaves an aisle. |
| `tiers` | `SeatTier[]` | – | Each tier: id, name, price, and optionally color. |
| `selected / defaultSelected / onSelectedChange` | `string[]` | – | The picked seat ids, controlled or not. Seats that turn taken are dropped from it. |
| `max` | `number` | `6` | The most seats one person can hold. |
| `initials` | `string` | `"You"` | Shown in your seats (first two letters). |
| `stage` | `string` | `"Screen"` | What the seats face. |
| `title / subtitle` | `string` | – | The showing, over the map. |
| `currency / locale` | `string` | `"USD"` | For prices and the total. |
| `onContinue` | `(ids) => void` | – | Called with the picked seats. |

## States

- **pick**: The seat fills with its tier’s colour and rises 2px (300ms) as your initials drop in from above with a small overshoot (380ms); the count and seat list morph and the total rolls.
- **taken by someone**: A seat that turns taken while you look flips over (460ms) and a ripple runs out from it: seats within three and a half places brighten and swell slightly, each 55ms later than the one before.
- **lost**: If it was one of yours it shakes (380ms), drops your initials and leaves your selection; the two nearest free seats in the same tier pulse twice. The change is announced.
- **limit**: Past max seats the count shakes and says why.
- **narrow**: Below 340px the row letters stay on the left only and the seats pack 3px apart, down to 13px each.
- **reduced motion**: Seats change colour in place; no rise, flip or ripple.

## What it handles

Seat grids are static: someone takes your seat while you choose and you only find out at checkout, with an error and no idea what’s left nearby.

- **Yours, visibly**: A picked seat rises with your initials; the list and total roll.
- **Live, and noticed**: A seat someone else takes turns over and ripples out through its neighbours.
- **Lost, with a way on**: If it was yours, it lets go and the nearest free seats in the tier pulse.
- **Tiers and aisles**: Prices by tier in your colours; leave a gap in a row for an aisle.
- **Fits a phone**: Seats pack tighter on narrow screens and keep one row label.
- **Keyboard and screen readers**: A grid with one tab stop and arrow keys; every seat says its row, number and price.

## Replaces

a seat picker, a seating chart, a seat selection grid, a venue map, a desk booking grid

## Where it fits

- **Cinemas and theatres**: Choosing seats for a showing, with premium rows priced apart.
- **Events and concerts**: Reserved seating while tickets sell in real time.
- **Flights and trains**: Picking a seat at check-in, with tiers by legroom.
- **Desks and classrooms**: Booking a desk in a shared office or a seat in a class.

## Notes

- The map is a grid with one tab stop; arrow keys move to the nearest seat in that direction; each seat says its row, number and price or that it’s taken; picks, losses and the limit are announced politely.
- Seats turning taken are found by comparing the rows you pass with the last ones, so the map works with polling, websockets or optimistic updates alike.
- Seat sizes come from the map’s own width, so it fits a phone, a sidebar or a modal without a scrollbar.
- Installs Number roll and Text morph. With reduced motion seats change in place.

License: MIT (https://hairlineui.com/license#components)
