# ViewPills: saved views that are addresses

ViewPills draws the saved views of one list, such as All, In progress and Overdue, as links in the pill look, the current one marked. Each view is the same route with another query, so it has its own address, survives a reload and can be shared, and saved views never become sidebar items.

Checked 2 December 2026. By Bohuslav Poláček. https://meadowstack.com/components/view-pills/

*Stonebridge's schedule with its four views and the View menu beside them, then the starter's purchase requests while the list loads, rendered from the kit. Under the schedule are the addresses the pills link to. In the app the current pill's fill slides to it; here it is drawn in place.*

A live screen, rendered from the kit's components on the page: https://meadowstack.com/components/view-pills/

## What it is for, and what the preview shows

ViewPills is the row of saved views above a list: All, Mine, Overdue. Each pill is a link to the same list with another query; the current one is marked for the eye and for screen readers (`aria-current="page"`), and a pill may carry a count. Because every view is an address, people can bookmark it, share it and come back to it with the browser's back button.

The preview shows the schedule of [Stonebridge](https://meadowstack.com/examples/construction-site-management/), a building firm in the demo, with four views (All, In progress, Overdue, At risk from weather) and, beside them, the View menu that sets the chart's scale. Under it are the four addresses: one route, four queries. Then come the starter's purchase requests, whose pills sit in a [FilterBar](https://meadowstack.com/components/filter-bar/) and get their counts once the list has loaded.

## The rules, and where each one lives

- **Saved views are links, not sidebar items.** The root `AGENTS.md` (navigation) puts saved views of the same entity into ViewPills and the command palette; another entity gets its own sidebar item. Decision 0009 set it, and `docs/patterns.md` names Stonebridge and the starter as where it runs.
- **One route, another query.** The runtime audit's `no-entity-switch` fails a screen whose pills lead to different routes (`docs/audit.md`), and ViewPills logs an error in development when its views point at two paths (`docs/patterns.md`).
- **Not another presentation.** List, board or calendar, day, week or month, is one `DisplayMenu` button, like the View menu beside the pills in the preview; the demo's old `ViewSwitch` fails the static audit (`view-switch`).
- **Not a filter in place.** A filter that does not change the address is a `SegmentedControl` in a FilterBar (the manifest's `not`).
- **One row.** The pills share the one row above the content (`control-rows`); when they overflow, they fade at the cut edge and scroll, with chevrons on hover (`AGENTS.md`).

## What AI coding tools write instead

The manifest's `replaces` lists three habits: sidebar items for saved views, `Tabs` that only change a query, and hand-built link pills. Asked for "Mine" and "Overdue", an assistant adds two sidebar items or wraps the list in tabs.

Sidebar items for views of one list fill the navigation with near-duplicates and break the rule that the current sidebar item names the page (the audit's `nav-matches-crumbs`). Tabs keep the view in component state: the address does not change, a reload drops back to All, and a view cannot be sent to a colleague. Hand-built pills drift in size and in how the current one looks from screen to screen. ViewPills keeps every view an address and the look the same on every list.

## How to use it

The props, from its exported `ViewPillsProps`:

- `views`: `{ id, label, href, count? }[]`. Build every `href` with one helper, so the views share a route.
- `current`: the id of the view on screen, read from the address.
- `label`: the group's accessible name ("Show work").
- `className`: `min-w-0 flex-1` when a `DisplayMenu` sits beside the pills.

The links go through the app shell's `renderLink`, so they navigate inside the app. Leave `count` out until the list has loaded, as the starter does, and put the pills into a FilterBar when the list has a search. Both belong to the [list pattern](https://meadowstack.com/patterns/list/).

## Its entry in the manifest

*The component's rules as the kit's manifest states them, the same entry an AI coding tool reads.*

| Manifest field | ViewPills |
| --- | --- |
| What it is | Saved views of one list as links in the pill look, the current one marked. |
| Use it for | Saved views of the same entity on one route (Vše, Moje, Po splatnosti), each its own address. |
| Not for | For a filter applied in place (SegmentedControl in a FilterBar); For another presentation of the same page (DisplayMenu); For different pages (the sidebar) |
| It replaces | Sidebar items for saved views; Tabs that only change a query; Hand-built link pills |
| Screen types | Index; Worklist; Workspace |
| Import | `import { ViewPills } from "@meadowstack-studio/kit";` |

Read from the kit's component manifest when the site was built (126 components, packages/kit/src/components.json); the same entry answers an AI coding tool through the kit's MCP server.

## Where it runs in the example apps

*The example apps whose code renders ViewPills, and in which modules, read from the demo's source.*

| Example app | Modules that render it |
| --- | --- |
| [An app for a construction company](https://meadowstack.com/examples/construction-site-management/) | Schedule |

Read from the demo's source when the site was built: 1 of 9 example apps render <ViewPills>, in the modules named here as each app's sidebar names them.

## How Stonebridge builds its views

*The schedule counts each view with the same tests it filters the chart by, and builds every address with one helper, so all four pills land on the same route.*

From `apps/demo/src/modules/schedule/components/schedule-board.tsx` in the Meadowstack repository:

```tsx
const counts = {
  all: tasks.length,
  running: tasks.filter(matches.running).length,
  late: tasks.filter(matches.late).length,
  weather: tasks.filter(matches.weather).length,
};
const views = (Object.keys(filterParam) as Filter[]).map((value) => ({
  id: value,
  label: filterLabel[value],
  count: counts[value],
  href: filterHref(value),
}));
```

## Questions

### When are ViewPills better than tabs?

When the views are the same list with another filter. A view that is a link has its own address, so a reload, the back button and a shared link keep it; tabs that only change a query lose it.

### Can a view lead to another page?

No. Every pill leads to the same route with another query, and the review audit fails a screen where one does not. Another entity gets its own sidebar item.

### Where do a board view and a calendar view go?

Into DisplayMenu, one button beside the pills. Another presentation of the same page is not a saved view, so it does not get a pill.

### Should every pill show a count?

Where the count tells something, and only once the list has loaded. Until then the pills show their labels alone, so no number jumps from zero to its value.

### What happens when the pills do not fit?

They scroll inside their row and fade at the cut edge, with chevrons on hover, so the row above the list stays one line.

## Related

- [FilterBar: the one row above a list](https://meadowstack.com/components/filter-bar/) (Components)
- [AsyncState: every data view has four states](https://meadowstack.com/components/async-state/) (Components)
- [BulkBar: what to do with the selection](https://meadowstack.com/components/bulk-bar/) (Components)
- [DataTable: the table of every list](https://meadowstack.com/components/data-table/) (Components)
- [RecordPeek: open a record without losing the list](https://meadowstack.com/components/record-peek/) (Components)
- [Loading, error, empty and no results](https://meadowstack.com/patterns/data-states/) (Patterns)
