Tree
A hierarchical list of nodes built from nested <details> and <summary> elements.
packages
ui
components
tree.tsx
table.tsx
mixins
treeKeys.ts
package.json
result
index.ts
View code
let model = new SelectionModel({
mode: "multiple",
keys,
selectedKeys: ["packages/ui/package.json"],
});
model.addEventListener("change", () => void handle.update());
<Tree aria-label="Repository files" aria-multiselectable="true" mix={[treeKeys(model)]}>
<Tree.Item id="packages" open>
<Tree.ItemContent data-tree-item="packages" aria-expanded="true">
<Tree.ExpandButton />
<FolderIcon aria-hidden="true" />
packages
</Tree.ItemContent>
<Tree.Item id="packages-ui" open>
<Tree.ItemContent data-tree-item="packages/ui" aria-expanded="true">
<Tree.ExpandButton />
<FolderIcon aria-hidden="true" />
ui
</Tree.ItemContent>
<Tree.Item id="packages-ui-components">
<Tree.ItemContent data-tree-item="packages/ui/components" aria-expanded="false">
<Tree.ExpandButton />
<FolderIcon aria-hidden="true" />
components
</Tree.ItemContent>
<Tree.Item id="packages-ui-components-tree">
<Tree.ItemContent data-tree-item="packages/ui/components/tree.tsx">
<FileCodeIcon aria-hidden="true" />
tree.tsx
</Tree.ItemContent>
</Tree.Item>
<Tree.Item id="packages-ui-components-table">
<Tree.ItemContent data-tree-item="packages/ui/components/table.tsx">
<FileCodeIcon aria-hidden="true" />
table.tsx
</Tree.ItemContent>
</Tree.Item>
</Tree.Item>
<Tree.Item id="packages-ui-mixins">
<Tree.ItemContent data-tree-item="packages/ui/mixins" aria-expanded="false">
<Tree.ExpandButton />
<FolderIcon aria-hidden="true" />
mixins
</Tree.ItemContent>
<Tree.Item id="packages-ui-mixins-tree-keys">
<Tree.ItemContent data-tree-item="packages/ui/mixins/treeKeys.ts">
<FileCodeIcon aria-hidden="true" />
treeKeys.ts
</Tree.ItemContent>
</Tree.Item>
</Tree.Item>
<Tree.Item id="packages-ui-package-json">
<Tree.ItemContent data-tree-item="packages/ui/package.json">
<FileBracesIcon aria-hidden="true" />
package.json
</Tree.ItemContent>
</Tree.Item>
</Tree.Item>
<Tree.Item id="packages-result">
<Tree.ItemContent data-tree-item="packages/result" aria-expanded="false">
<Tree.ExpandButton />
<FolderIcon aria-hidden="true" />
result
</Tree.ItemContent>
<Tree.Item id="packages-result-index">
<Tree.ItemContent data-tree-item="packages/result/index.ts">
<FileCodeIcon aria-hidden="true" />
index.ts
</Tree.ItemContent>
</Tree.Item>
</Tree.Item>
</Tree.Item>
</Tree>Demo apps
Whole pages built only from @sdxc/ui, each for an invented product with its own palette and type. They open in a new tab.
- Food deliveryBocadoBocado, an invented food delivery app: restaurants by cuisine and delivery time, search with filters, menus with options, a cart, checkout and live order tracking on a drawn map./showcase/bocado/demo
- Issue trackerCairnCairn, an invented issue tracker: grouped issue lists with filters in the address, a drag-and-drop board, projects on a roadmap, cycles with burn-up charts and an inbox./showcase/cairn/demo
- Social networkChorusChorus, an invented social network: a live timeline with pictures, link cards, polls and threads, profiles, grouped notifications, search and messages./showcase/chorus/demo
- Code hostDeltaDelta, a code host whose one repository is its own source: a file tree beside the code, line links, blame and the commits list, every file and commit read from git when the site is built./showcase/delta/demo
- Online storeHangwellHangwell, an invented poster shop: collections with facet filters, product pages with format, size and frame pickers and a room preview, a bag, a checkout that adapts to print files, order tracking, downloads and returns./showcase/hangwell/demo
- CMSInkwellInkwell, a demo CMS built from @sdxc/ui/app: posts with count tabs and quick edit, an editor with a quiet save status and a loud Publish, media and settings./showcase/inkwell/demo
- Music streamingMurmurMurmur, an invented music service: home shelves, search by genre, a library, albums, playlists and artists, with a player that keeps playing while you browse./showcase/murmur/demo
- Team chatParleyParley, an invented team chat: channels and direct messages with unread and mention badges, threads, reactions, edits, pins, search, a quick switcher and teammates who type and post live./showcase/parley/demo
- Photo and video networkPinholePinhole, an invented social network for photographs and short videos: a feed under a story tray, full-screen stories, a vertical reels feed, profiles with highlights, Explore and posts with comments./showcase/pinhole/demo
- Ops dashboardPulsePulse, an invented ops dashboard: Northwind's services with live filters, a peek sheet and a bulk bar, metrics that switch one chart, incidents, deploys and settings./showcase/pulse/demo
- Support inboxRelayRelay, an invented support inbox: mailboxes, conversations and the open conversation on one screen, with contacts, reports and settings./showcase/relay/demo
- CalendarSundialSundial, an invented calendar: day, week and month views, an agenda, events you drag, resize and create on the grid, a second time zone, and a find-a-time view across a team in five zones./showcase/sundial/demo
- Chat assistantTernTern, an invented chat assistant: conversations with streamed replies, code and tables, projects, a canvas, sharing and settings./showcase/tern/demo
- Banking & budgetsTuppenceTuppence, an invented personal bank: multi-currency accounts, a statement by day with search and splits, spending and budgets, savings pots, bills ahead, cards that freeze and a transfer flow, all with fake money./showcase/tuppence/demo
- Streaming serviceVesperVesper, an invented streaming service: profiles, a home of sideways shelves under a billboard, series with seasons and episodes, search, My List and a theater player./showcase/vesper/demo
- Travel bookingWayfernWayfern, an invented travel app: stays, flights, cars and packages from one search, results on a real map, seat maps and boarding passes, and one itinerary of trips that exports to calendars./showcase/wayfern/demo
Every demo, landings and docs sites alike, is listed in the showcase.
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 { Tree } from "@sdxc/ui/app";Renders the bordered role="tree" panel; folders open and file links work with no script.
Rows indent --ui-tree-indent per level, frame aims every Tree.Leaf at one frame,
data-empty centers a fallback, Tree.NoMatches answers a filter that matches
nothing, and Tree.Filter and Tree.Navigation add islands.
Composition
The parts the component publishes, each a static property of the host.
TreeTree.ItemContentRenders Tree.ItemContentProps.children inside a native<summary>— the enclosing Tree.Item's always-visible row — indented from its ambient depth, witharia-selected/aria-disabledstyling.Tree.ExpandButtonRenders the chevron a node's row shows for a subtree, rotated 90 degrees while the enclosing Tree.Item's<details>carries[open].Tree.LeafRenders a file: a link row with the file's icon and name, indented from the depth of the folders around it, as arole="treeitem"so arrow keys reach it beside the folders.Tree.FilterRenders a "Go to file" field over a tree: a GET form (?filter=by default), so without script the server renders the narrowed tree with treeFilterMatches.Tree.NoMatchesRenders the line a tree shows while its filter matches no file, such as "No file matches", inside the tree or beside it withtreenaming the tree's id.Tree.NavigationAdds the keys as the TreeNavigation island running treeNavigation: ↑↓ andj/kbetween visible rows, → opens or enters a folder, ← closes it or goes up, Home/End and type-ahead.
Examples
Changed files, with a filter and the arrow keys
View code
<Tree.Filter tree="changed-files" label="Filter changed files" placeholder="Filter changed files…" action="/acme/delta/pull/412/files" />
<Tree id="changed-files" aria-label="Changed files" frame="diff">
<Tree.Navigation labels={{ group: "Changed files" }} />
<Tree.Item id="src" open>
<Tree.ItemContent aria-expanded="true">
<Tree.ExpandButton />
<FolderIcon aria-hidden="true" />
src
</Tree.ItemContent>
<Tree.Item id="src-lexer" open>
<Tree.ItemContent aria-expanded="true">
<Tree.ExpandButton />
<FolderIcon aria-hidden="true" />
lexer
</Tree.ItemContent>
<Tree.Leaf
href="/acme/delta/pull/412/files#diff-identifier"
name="identifier.ts"
path="src/lexer/identifier.ts"
current
status="modified"
statusLabel="Modified"
additions={18}
deletions={4}
/>
<Tree.Leaf href="…" name="unicode.ts" path="src/lexer/unicode.ts" status="added" statusLabel="Added" additions={96} />
…
</Tree.Item>
</Tree.Item>
</Tree>Empty
View code
<Tree aria-label="Files" data-empty>
No files in this folder yet.
</Tree>Props
Read from the component's own types, so every prop, every default and every allowed value is listed.
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
children | RemixNode | — | Yes | Tree.Item, Tree.Leaf and Tree.LoadMoreItem nodes to render. |
frame | string | — | No | The frame every file link swaps (data-rmx-target), such as "main", so picking a file redraws only the code while the tree, its open folders and scroll stay put. |
Also accepts everything in TagProps<"div">.
Tree.ItemContent
Also accepts everything in TagProps<"summary">.
Tree.ExpandButton
Also accepts everything in TagProps<"span">.
Tree.Leaf
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
href | string | — | Yes | |
name | string | — | Yes | The file's name; picks its icon and is what type-ahead matches. |
path | string | — | No | The file's full path, which Tree.Filter matches. @default name |
children | RemixNode | — | No | What the row shows in place of name, such as a name with a matched part marked. |
current | boolean | — | No | Marks the file being read, with aria-current="page"; render its folders open. |
frame | string | — | No | The frame this link swaps, over the tree's own frame. |
status | "added" | "modified" | "deleted" | "renamed" | — | No | |
statusLabel | string | — | No | What assistive technology reads for status, such as "Modified"; the letter is decoration. |
additions | number | — | No | Lines added, drawn end-aligned as +n. |
deletions | number | — | No | Lines removed, drawn end-aligned as −n. |
Also accepts everything in Omit<TagProps<"a">, "children" | "role" | "href">.
Tree.Filter
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
tree | string | — | Yes | The id of the Tree the field narrows as the reader types. |
label | string | — | Yes | The field's accessible name, such as "Filter files". |
placeholder | string | — | No | |
value | string | — | No | The query the page was rendered with, so the field shows what narrowed the tree. |
name | string | — | No | Search parameter the query submits under. @default "filter" |
params | Record<string, string> | — | No | Other search parameters the submission keeps, as hidden fields. |
Also accepts everything in Omit<TagProps<"form">, "children" | "method">.
Tree.NoMatches
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
tree | string | — | No | The id of the tree it answers for, when it sits beside the tree rather than inside it, which keeps the tree's children to its items. |
Also accepts everything in TagProps<"p">.
Tree.Navigation
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
labels | TreeNavigationMixin.Labels | — | No |
Types
| Name | Values | What it decides |
|---|---|---|
LeafStatus | "added" | "modified" | "deleted" | "renamed" | How a file changed, drawn as a toned letter: A, M, D or R. |