# FareCalendar

> A flexible-dates fare calendar: a month of departure days, or a scrolling strip of days around the chosen one, each showing its lowest fare with the cheapest days tinted and named so.

```ts
import { FareCalendar } from "@sdxc/ui/travel";
```

Renders a month `<table>` with previous and next links, or, as `"strip"`, a `<nav>` named by
`label` around a scrolling row of day cards. A day with a fare links to `href(day)`, named by
its full date, fare and, at the `"low"` level, `labels.cheapest`; a day without one is text.

## Examples

```tsx
<FareCalendar
	month="2026-03"
	fares={fares}
	selected="2026-03-14"
	href={(day) => `?depart=${day}`}
	prevHref="?month=2026-02"
	nextHref="?month=2026-04"
	locale="en-US"
	label="Departure dates"
	labels={{ previous: "Previous month", next: "Next month", cheapest: "cheapest", noFlights: "no flights" }}
/>
```

```tsx
<FareCalendar variant="strip" days={week} fares={fares} selected={day} href={href} locale={locale} label="Nearby dates" labels={labels} />
```

## Props

| Prop | Type | Description |
| --- | --- | --- |
| `variant?` | `"month" \| "strip"` | `"strip"` draws `days` as one scrolling row instead of a month grid. @default "month" |
| `month?` | `string` | The month the grid shows, `YYYY-MM`; the strip ignores it. |
| `days?` | `string[]` | The days the strip shows, `YYYY-MM-DD`, usually a few either side of `selected`. |
| `fares` | `Record<string, Fare \| undefined>` | Each day's lowest fare by `YYYY-MM-DD`; a missing or `undefined` entry means no flights. |
| `selected?` | `string` | The chosen day, `YYYY-MM-DD`, marked as the current page and scrolled into the strip's view. |
| `href` | `(day: string) => string` | Builds the URL a day links to. |
| `prevHref?` | `string` | The previous link's URL; the link is left out when unset. |
| `nextHref?` | `string` | The next link's URL; the link is left out when unset. |
| `today?` | `string` | Today, `YYYY-MM-DD`, passed in so the server and the browser draw the same marker. |
| `weekStartsOn?` | `number` | First weekday column, 0 for Sunday through 6 for Saturday. @default 0 |
| `locale` | `string` | BCP 47 locale for the month, weekday and day names; server and browser must agree on it. |
| `label` | `string` | Names the whole calendar, e.g. "Departure dates". |
| `headingLevel?` | `Heading.Level` | Level of the month's heading; resolved from the surrounding heading scope when unset. |
| `labels` | `Labels` |  |

Also accepts everything in `Omit<TagProps<"div">, "children">`.


## Types

| Name | Values | What it decides |
| --- | --- | --- |
| `Level` | `"low" \| "mid" \| "high"` | How a day's fare compares with the others on view; `"low"` marks the cheapest. |
