SeatMap
An aircraft cabin seat picker.
View code
<form method="post">
<SeatMap
name="seat"
label="Choose a seat"
labels={{ taken: "taken", aisle: "aisle", window: "window", exit: "exit row", kinds: { "extra-legroom": "extra legroom", exit: "exit seat" } }}
layout="ABC DEF"
rows={rows}
selected="14C"
deck="Main deck · LK 482"
exitRows={[12]}
wings={[12, 17]}
sections={[{ from: 10, title: "Larkwing Plus" }, { from: 11, title: "Economy" }]}
/>
<SeatMap.Legend
items={[
{ swatch: "available", label: "Available" },
{ swatch: "selected", label: "Your seat" },
{ swatch: "extra-legroom", label: "Extra legroom" },
{ swatch: "exit", label: "Exit row" },
{ swatch: "taken", label: "Taken" },
]}
/>
</form>Installation
An ordinary dependency: install it, import the theme once, and import the component where it is used.
npm add @sdxc/ui remiximport "@sdxc/ui/theme.css";Usage
import { SeatMap } from "@sdxc/ui/travel";Renders the cabin as a <fieldset> named by label. Each seat is a radio named name with
the seat's id as its value, so the pick posts with the form and arrow keys move through the
cabin natively; taken and blocked seats are disabled radios.
Composition
The parts the component publishes, each a static property of the host.
SeatMapSeatMap.LegendRenders the key to the cabin: a wrapping list of swatches drawn exactly like the seats they explain, each beside the caller's caption.
Props
Read from the component's own types, so every prop, every default and every allowed value is listed.
| Prop | Type | Required | Description |
|---|---|---|---|
rows | Row[] | Yes | |
layout | string | Yes | Seat letters in cabin order, a space for each aisle, e.g. "ABC DEF". |
name | string | Yes | The form field the picked seat's id posts under. |
selected | string | No | The seat id checked on load. |
label | string | Yes | Names the radio group for assistive technology, e.g. "Choose a seat". |
labels | Labels | Yes | |
deck | RemixNode | No | A visible header under the nose, such as "Main deck · Larkwing A321". |
wings | [number, number] | No | First and last rows the wing spans, drawn on both walls. |
exitRows | number[] | No | Rows with an emergency exit, marked on both walls. |
sections | Section[] | No | Section titles, each drawn above the row it starts at. |
required | boolean | No | Asks the browser to require a pick before the form submits. |
Also accepts everything in Omit<TagProps<"fieldset">, "children">.
SeatMap.Legend
| Prop | Type | Required | Description |
|---|---|---|---|
items | LegendItem[] | Yes |
Also accepts everything in Omit<TagProps<"ul">, "children">.
Types
| Name | Values | What it decides |
|---|---|---|
Status | "available" | "taken" | "blocked" | Whether a seat can be picked; "taken" and "blocked" seats render disabled. |
Kind | "standard" | "extra-legroom" | "exit" | "premium" | What a seat offers; every kind but "standard" is tinted. |
Swatch | "available" | "selected" | "taken" | "blocked" | What one legend entry explains. |