# Shared fields and links

A page's `cards` array sets the order from top to bottom. There are twenty-nine card types; [Features](https://legatobar.com/features) shows each one alongside its example JSON.

`stat`, `status` (unless `"width": "full"`), `countdown` and `gauge` cards are half width, as are a `pacing` ring, a `link` tile and a `sparkline` with `"width": "half"`. Two consecutive half-width cards share a row. Everything else takes the full width.

| Type | For |
| --- | --- |
| [`stat`](https://legatobar.com/docs/card-numbers.md#stat) | One headline number: a balance, open PRs, uptime |
| [`pacing`](https://legatobar.com/docs/card-numbers.md#pacing) | Progress against a target: budget pace, a sprint, a ring for today's steps |
| [`list`](https://legatobar.com/docs/card-lists.md#list) | Up to 60 short lines: largest charges, new deals |
| [`table`](https://legatobar.com/docs/card-lists.md#table) | A small grid, up to 4 columns and 10 rows |
| [`sparkline`](https://legatobar.com/docs/card-numbers.md#sparkline) | A trend line of up to 240 points |
| [`status`](https://legatobar.com/docs/card-lists.md#status) | The health of one service or job |
| [`text`](https://legatobar.com/docs/card-text.md#text) | A short note, up to 500 characters |
| [`link`](https://legatobar.com/docs/card-text.md#link) | A button that opens an https URL or another page |
| [`countdown`](https://legatobar.com/docs/card-time.md#countdown) | Time until a moment: a flight boards, a domain renews |
| [`window`](https://legatobar.com/docs/card-time.md#window) | A window in the day: daylight left, opening hours, off-peak charging |
| [`map`](https://legatobar.com/docs/card-lists.md#map) | Places on Apple's map: the car, a package, a trip's stops |
| [`facts`](https://legatobar.com/docs/card-lists.md#facts) | A few labelled values: order number, carrier, ETA |
| [`gauge`](https://legatobar.com/docs/card-numbers.md#gauge) | A value in a range with coloured bands: CPU temperature, air quality |
| [`bars`](https://legatobar.com/docs/card-numbers.md#bars) | Categories with values: spend by category, votes |
| [`breakdown`](https://legatobar.com/docs/card-numbers.md#breakdown) | Parts of one whole in one coloured bar: net worth by asset, a budget by category |
| [`flow`](https://legatobar.com/docs/card-numbers.md#flow) | Where amounts go: DNS queries from each device to allowed and blocked, solar and grid to the house and the car |
| [`ranges`](https://legatobar.com/docs/card-numbers.md#ranges) | Rows from low to high on one scale: a week of temperatures, a price's daily range |
| [`columns`](https://legatobar.com/docs/card-numbers.md#columns) | Periods side by side, one to three series: income against spending by month |
| [`tiles`](https://legatobar.com/docs/card-numbers.md#tiles) | Small tiles four across, each a label, a value and a change, tinted by how far it moved: a watchlist |
| [`fleet`](https://legatobar.com/docs/card-lists.md#fleet) | A dot per host or job, up to 60 |
| [`checklist`](https://legatobar.com/docs/card-lists.md#checklist) | Up to 20 items, done or not |
| [`agenda`](https://legatobar.com/docs/card-time.md#agenda) | A day, a week or up to 30 days of meetings, trips, deadlines and bills, with a line at now |
| [`month`](https://legatobar.com/docs/card-time.md#month) | This month as a grid with a dot on each busy day, and the chosen day's items |
| [`timeline`](https://legatobar.com/docs/card-time.md#timeline) | A dated history newest first: a package's tracking, a job's runs, an order's steps |
| [`strip`](https://legatobar.com/docs/card-time.md#strip) | An item's states over a span, a thin bar per slice: a monitor's last day |
| [`heatmap`](https://legatobar.com/docs/card-time.md#heatmap) | A square per day in week columns, shaded by how much: a year of contributions or steps |
| [`code`](https://legatobar.com/docs/card-text.md#code) | A block of code or a command, monospaced, with a Copy button |
| [`heading`](https://legatobar.com/docs/card-text.md#heading) | A section title that splits a long page into parts, which can open and close |
| [`tabs`](https://legatobar.com/docs/card-text.md#tabs) | Two to five tabs in one place, each with its own cards: several feeds, today and this week, one server each |

The [page schema](https://legatobar.com/docs/page-writing.md#the-schema) has every card type with its fields and limits, as JSON Schema (draft-07): in your Pages folder at `.schemas/page.schema.json`, at [legatobar.com/schemas/page.schema.json](https://legatobar.com/schemas/page.schema.json), and from `get_page_schema` or `legato schema <type>`, one type at a time. If this page and the schema ever disagree, the schema is right.

## Fields every card has

| Field | | |
| --- | --- | --- |
| `id` | required | Unique within the page. 1–64 characters: lowercase letters, digits, `-` and `_`, starting with a letter or digit. Keep ids stable between writes. |
| `type` | required | One of the twenty-nine types. |

Each type accepts only the fields listed for it, and the schema flags a misspelled field (`"lable"`) in your editor. Legato itself refuses a card that's missing a required field or has the wrong kind of value, saying which (`a stat card needs label`), and ignores a field it doesn't know, so check new pages against the schema. Wherever a card has a `label`, it's 1–60 characters; a `unit` is 1–16.

A three-letter currency code as `unit` (`USD`, `EUR`, `GBP`, …) formats numbers as money in the Mac's locale, with cents only when the number has them: `4218.55` with `USD` shows as `$4,218.55`, and `1060` as `$1,060`. Any other unit is shown as is after the number.

## Links to other pages

Wherever a card takes a link (a `list` row, a `facts` line, a `bars` row, a `link` card, a `fleet` item, a `tiles` tile, an `agenda` or `month` item, or a Markdown link in text), it can be another of your pages instead of a web address: `legato://page/ID`, where ID is the page's id as `legato list` and `list_pages` show it, the file's name without `.json`, matched exactly (case included), with a space written `%20` (`legato://page/My%20Page`). Nothing else goes in the address: no other `%` escapes and no port. A query is for one thing, a page's [params](https://legatobar.com/docs/detail-pages.md#one-page-for-every-item) (`legato://page/proxmox-vm?vmid=109`), and a `#` part for another, a card (below). A click shows that page in the panel, as choosing it in the sidebar does, and **Back** returns. The arrow is → rather than ↗, and the tooltip names the page ("Show the Pi-hole page"). A link to a page that doesn't exist (removed, or not made yet) isn't drawn as a link: a row or item shows its words, and a `link` card shows its label with "Page unavailable". The welcome pages work too: `legato://page/getting-started`. A page meant only to be reached this way can stay out of the sidebar: see [Detail pages](https://legatobar.com/docs/detail-pages.md#detail-pages).

### Links to a card

Add `#` and a card's id to bring that card into view: `legato://page/net-worth#cards`. Legato shows the page, chooses the tab that holds the card if it's in a [tabs](https://legatobar.com/docs/card-text.md#tabs) card, opens its section if a closed [heading](https://legatobar.com/docs/card-text.md#heading) holds it, and scrolls to it, unless it's already in full view. On the page the link is on, nothing else changes: a Liabilities total can open the Liabilities tab below it, with no new step for **Back**. A link to a heading opens its section, and a link to a tabs card scrolls to its tab names. A card id that isn't on the page, such as a card hidden by its `when`, opens the page as it is. Card ids are written as they are on the page: lowercase letters, digits, `_` and `-`.

```json
{ "id": "liabilities", "type": "stat", "label": "Liabilities", "value": 55558, "unit": "USD", "url": "legato://page/net-worth#cards" }
```

The same address works outside Legato: in a note, a Raycast quicklink, Shortcuts' **Open URLs**, or `open legato://page/budget` in Terminal opens the panel on that page (your browser asks first). An address for a page that doesn't exist opens the panel where it was.

```json
{ "id": "services", "type": "fleet", "label": "Services", "items": [
  { "name": "Pi-hole", "state": "ok", "url": "legato://page/pihole" },
  { "name": "Gitea", "state": "ok", "url": "https://gitea.example.com" } ] }
```

## Cards that link

For help choosing the structure, see [Page design](https://legatobar.com/docs/design.md#choose-the-right-structure), including a [linked overview and detail example](https://legatobar.com/docs/design.md#a-linked-overview-and-detail-example).

A `stat`, `status`, `breakdown` or `pacing` card with a `url` opens it when clicked. Without buttons, the whole card is the link: under the pointer (or with keyboard focus) it lights a little and shows its arrow, → for a page and ↗ for a web address, and its tooltip says where it goes. With buttons, a click on the card is never a press: the link is its own small button at the end of the row, named for the page or the site. Together with a [condition](https://legatobar.com/docs/mapping-conditions.md#cards-that-show-on-a-condition), a card can appear only when something needs attention and lead straight to the page about it.

## Item icons

Items on `bars`, `pacing` (rows), `breakdown`, `facts`, `checklist`, `list`, `agenda`, `month` and `timeline` cards can carry an `icon`, drawn at the start of the row, before the label and never inside a bar. When any item on a card has one, every row keeps its space, so the labels line up.

A symbol is grey, as the row's other supporting marks are. On `facts`, `bars`, `list`, `pacing` rows and `ranges`, an item can also name a `color` for its icon, by the [breakdown](https://legatobar.com/docs/card-numbers.md#breakdown) names: `blue`, `teal`, `orange`, `purple`, `green`, `pink`, `yellow`, `red`, `rose` or `grey`. Use it when the colour means something, such as a category's colour on other pages; leave it out otherwise. A breakdown's icons always take their part's colour. See [Card style](https://legatobar.com/docs/design.md#card-style).

```json
{ "key": "Resting", "value": "61 bpm", "icon": "heart", "color": "pink" }
```

| `icon` | Draws |
| --- | --- |
| `creditcard`, `cart`, `fork.knife` | That SF Symbol, in grey. |
| `si:chase`, `si:paypal` | A logo from [Simple Icons](https://simpleicons.org), in the text's colour. |
| `di:paypal`, `di:nocodb` | An icon from [Dashboard Icons](https://dashboardicons.com): in the text's colour by default, or in its own colours with **Show logos in one colour** off. |
| `mdi:cash`, `mdi:airplane` | An icon from [Material Design Icons](https://pictogrammers.com/library/mdi/), in the text's colour. |
| `site:citi.com` | The website's own icon: the sharpest of its Apple touch icon, the icons its homepage names and `/favicon.ico`. By default it's drawn like the one-colour sets, in the text's colour with its background taken out, so logos from different sites look like one set. With **Show logos in one colour** off, it keeps its brand colours, as a glass tile. |

`si:`, `di:` and `mdi:` are the names [Glance](https://github.com/glanceapp/glance) uses, so icons from a Glance config carry over.

The Mac downloads each web icon once, from jsDelivr or the named site only, keeps it, and asks again after 30 days; one that fails is tried again the next day, and its row stays blank meanwhile.

**Settings → General → Load icons from the web** turns downloads off; rows then show only SF Symbols. **Show logos in one colour**, beside it, is how each Mac chooses between one-colour logos (the default) and brand colours. Anything else in `icon` draws nothing.

A card filled from a [source](https://legatobar.com/docs/mapping.md#mapping) can choose an icon per row from the answer with `values`, such as a bank's icon from its name:

```json
"icon": { "path": "institution_name", "values": { "Chase": "site:chase.com", "Citibank Online": "site:citi.com" }, "default": "creditcard" }
```

`si:` logos are drawn from vectors, so where Simple Icons has a brand it's the crisper choice; `site:` covers the rest.

