App components / Tree views
Outline
A page's headings as a nested list beside a long document. The current heading gets the accent rule, which follows the reader as they scroll.
Code
The component itself, ready to drop into your project. Switch between React, Vue and plain HTML; every version uses the same Tailwind classes on Ochre's tokens.
Summary
Northwind finance approves every invoice twice. This spec moves approval into the invoice itself, so one person signs off and the second check happens only above the limit.
The problem
Approvals happen in email threads that nobody else can see.
How invoices work today
An invoice arrives, Maya Shah forwards it to the budget owner, waits for a reply and then pays it from the bank portal. The thread is the only record.
What it costs us
Invoices wait for a reply more often than they wait for money. Late fees follow, and suppliers start chasing the wrong person.
Proposal
Approval moves onto the invoice page, with the budget owner named on it.
The new flow
The invoice page shows who owns the budget, the amount left this quarter and one Approve button. Sam Okafor approves; payment is scheduled the same day.
Rollout
Finance first, on NW-118 and the Q3 roadmap budgets, then every team once the limits are set.
Open questions
Who approves when the budget owner is away? Do we keep the email as a fallback for a quarter?
Installation
Examples
Collapsible
Sections with subheadings open and close.
Motion
Built on Ochre's ease-out curves. With reduced motion switched on, everything still works, it just doesn't move.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| items | { id; label; children? }[] | – | The headings, nested. Each id is a heading element's id. |
| title | string | "On this page" | The mono label above the list, and the nav's name. |
| active / defaultActive | string | null | – | The current heading: strong text, the orange rule and aria-current. |
| onNavigate | (id: string) => void | – | Called when a heading is picked. Pass it to scroll yourself; leave it out and the heading scrolls into view. |
| track / scrollRoot / offset | boolean / RefObject / number | false / window / 80 | Follows the reader: the last heading scrolled past the top plus offset becomes current. |
| collapsible / defaultExpanded | boolean / string[] | false | Sections with subheadings get a chevron and open and close with Right and Left. |
Usage
Use it for
- Docs, specs and long reports with three or more sections.
- Beside the text on wide screens; above it, or in a menu, on phones.
Avoid
- Short pages with one or two headings.
- Moving between pages: use a Sidebar or Tabs.
- More than two levels of headings: the third reads as noise.