Tree
A Liquid Glass hierarchical tree view with concentric geometry, neutral content-layer contrast, branch expansion, and RTL keyboard navigation.
Liquid Glass Tree manages an explicitly keyed hierarchy with single selection, expandable branches, and full keyboard and RTL navigation. Following Apple Liquid Glass HIG, tree content remains on a neutral legible surface rather than stacking glass-on-glass inside list rows, paired with concentric corner radii (rounded-2xl outer container, p-2 inset, rounded-lg rows) and readable disabled contrast.
Preview
Section titled “Preview”<proto-ui-liquid-glass-tree-root
id="project-tree"
class="w-full max-w-sm"
>
<div class="flex items-center gap-1">
<proto-ui-liquid-glass-tree-toggle data-toggle="src">
<span aria-hidden="true">▾</span>
<span class="sr-only">Toggle src</span>
</proto-ui-liquid-glass-tree-toggle>
<proto-ui-liquid-glass-tree-item data-node="src" class="flex-1">
src/
</proto-ui-liquid-glass-tree-item>
</div>
<proto-ui-liquid-glass-tree-group data-group="src">
<div class="flex items-center gap-1">
<proto-ui-liquid-glass-tree-toggle data-toggle="components">
<span aria-hidden="true">▾</span>
<span class="sr-only">Toggle components</span>
</proto-ui-liquid-glass-tree-toggle>
<proto-ui-liquid-glass-tree-item
data-node="components"
class="flex-1"
>
components/
</proto-ui-liquid-glass-tree-item>
</div>
<proto-ui-liquid-glass-tree-group data-group="components">
<proto-ui-liquid-glass-tree-item data-node="button">
button.tsx
</proto-ui-liquid-glass-tree-item>
<proto-ui-liquid-glass-tree-item data-node="tree">
tree.tsx
</proto-ui-liquid-glass-tree-item>
</proto-ui-liquid-glass-tree-group>
<proto-ui-liquid-glass-tree-item data-node="index">
index.ts
</proto-ui-liquid-glass-tree-item>
</proto-ui-liquid-glass-tree-group>
<proto-ui-liquid-glass-tree-item data-node="package">
package.json
</proto-ui-liquid-glass-tree-item>
<proto-ui-liquid-glass-tree-item data-node="readme">
README.md
</proto-ui-liquid-glass-tree-item>
</proto-ui-liquid-glass-tree-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector('#project-tree');
setElementProps(root, {
defaultValue: 'button',
defaultExpandedKeys: ['src', 'components'],
});
setElementProps(root.querySelector('[data-node="src"]'), {
nodeKey: 'src',
textValue: 'src',
});
setElementProps(root.querySelector('[data-toggle="src"]'), {
nodeKey: 'src',
size: 'icon',
});
setElementProps(root.querySelector('[data-group="src"]'), {
nodeKey: 'src',
});
setElementProps(root.querySelector('[data-node="components"]'), {
nodeKey: 'components',
parentKey: 'src',
textValue: 'components',
});
setElementProps(
root.querySelector('[data-toggle="components"]'),
{ nodeKey: 'components', size: 'icon' }
);
setElementProps(root.querySelector('[data-group="components"]'), {
nodeKey: 'components',
});
setElementProps(root.querySelector('[data-node="button"]'), {
nodeKey: 'button',
parentKey: 'components',
textValue: 'button.tsx',
});
setElementProps(root.querySelector('[data-node="tree"]'), {
nodeKey: 'tree',
parentKey: 'components',
textValue: 'tree.tsx',
});
setElementProps(root.querySelector('[data-node="index"]'), {
nodeKey: 'index',
parentKey: 'src',
textValue: 'index.ts',
});
setElementProps(root.querySelector('[data-node="package"]'), {
nodeKey: 'package',
textValue: 'package.json',
});
setElementProps(root.querySelector('[data-node="readme"]'), {
nodeKey: 'readme',
textValue: 'README.md',
});
</script>Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases. Import the prototypes from @proto.ui/prototypes-liquid-glass/tree and adapt them for your target runtime:
import { treeRoot, treeItem, treeGroup, treeToggle } from '@proto.ui/prototypes-liquid-glass/tree';<LiquidGlassTreeRoot defaultValue="button" defaultExpandedKeys={['src', 'components']}> <div className="flex items-center gap-1.5"> <LiquidGlassTreeToggle nodeKey="src" size="icon"> ▾ </LiquidGlassTreeToggle> <LiquidGlassTreeItem nodeKey="src" textValue="src" className="flex-1"> src/ </LiquidGlassTreeItem> </div> <LiquidGlassTreeGroup nodeKey="src"> <LiquidGlassTreeItem nodeKey="button" parentKey="src" textValue="button.tsx"> button.tsx </LiquidGlassTreeItem> </LiquidGlassTreeGroup></LiquidGlassTreeRoot>Layering & Interaction Semantics
Section titled “Layering & Interaction Semantics”- Neutral content layer & concentric radii: Because Tree presents scrollable/hierarchical content rather than floating chrome, it intentionally stays material-neutral (no glass-on-glass) while aligning outer container corners (
rounded-2xlwithp-2) concentrically with inner item rows (rounded-lg) and capsule disclosure toggles (rounded-full). - Accessibility & contrast: Focus uses an inset ring with
forced-colorsoutline fallback; disabled rows switch to semantic muted ink rather than washing out opacity so contrast stays legible under opaque and high-contrast preferences. - Keyboard & RTL: Up/Down,
Home/End, and first-letter typeahead move focus in visual order;direction="rtl"mirrors group indent guides and swaps Left/Right arrow keys.
Examples
Section titled “Examples”Controlled Selection & Expansion
Section titled “Controlled Selection & Expansion”Pass value and expandedKeys to synchronize selection and branch expansion externally via valueChange and expandedChange.
<div class="grid w-full max-w-sm gap-2">
<proto-ui-liquid-glass-tree-root id="controlled-tree">
<div class="flex items-center gap-1">
<proto-ui-liquid-glass-tree-toggle data-toggle="src">
<span aria-hidden="true">▾</span>
<span class="sr-only">Toggle src</span>
</proto-ui-liquid-glass-tree-toggle>
<proto-ui-liquid-glass-tree-item
data-node="src"
class="flex-1"
>
src/
</proto-ui-liquid-glass-tree-item>
</div>
<proto-ui-liquid-glass-tree-group data-group="src">
<div class="flex items-center gap-1">
<proto-ui-liquid-glass-tree-toggle data-toggle="components">
<span aria-hidden="true">▾</span>
<span class="sr-only">Toggle components</span>
</proto-ui-liquid-glass-tree-toggle>
<proto-ui-liquid-glass-tree-item
data-node="components"
class="flex-1"
>
components/
</proto-ui-liquid-glass-tree-item>
</div>
<proto-ui-liquid-glass-tree-group data-group="components">
<proto-ui-liquid-glass-tree-item data-node="button">
button.tsx
</proto-ui-liquid-glass-tree-item>
<proto-ui-liquid-glass-tree-item data-node="tree">
tree.tsx
</proto-ui-liquid-glass-tree-item>
</proto-ui-liquid-glass-tree-group>
</proto-ui-liquid-glass-tree-group>
<proto-ui-liquid-glass-tree-item data-node="readme">
README.md
</proto-ui-liquid-glass-tree-item>
</proto-ui-liquid-glass-tree-root>
<div id="tree-status" role="status" aria-live="polite">
Selected: button · Expanded: src, components
</div>
</div>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector('#controlled-tree');
const status = document.querySelector('#tree-status');
let value = 'button';
let expandedKeys = ['src', 'components'];
const sync = () => {
setElementProps(root, { value, expandedKeys });
status.textContent =
'Selected: ' +
value +
' · Expanded: ' +
(expandedKeys.join(', ') || 'none');
};
setElementProps(root.querySelector('[data-node="src"]'), {
nodeKey: 'src',
textValue: 'src',
});
setElementProps(root.querySelector('[data-toggle="src"]'), {
nodeKey: 'src',
size: 'icon',
});
setElementProps(root.querySelector('[data-group="src"]'), {
nodeKey: 'src',
});
setElementProps(root.querySelector('[data-node="components"]'), {
nodeKey: 'components',
parentKey: 'src',
textValue: 'components',
});
setElementProps(
root.querySelector('[data-toggle="components"]'),
{ nodeKey: 'components', size: 'icon' }
);
setElementProps(root.querySelector('[data-group="components"]'), {
nodeKey: 'components',
});
setElementProps(root.querySelector('[data-node="button"]'), {
nodeKey: 'button',
parentKey: 'components',
textValue: 'button.tsx',
});
setElementProps(root.querySelector('[data-node="tree"]'), {
nodeKey: 'tree',
parentKey: 'components',
textValue: 'tree.tsx',
});
setElementProps(root.querySelector('[data-node="readme"]'), {
nodeKey: 'readme',
textValue: 'README.md',
});
root.addEventListener('valueChange', (e) => {
value = e.detail.value;
sync();
});
root.addEventListener('expandedChange', (e) => {
expandedKeys = e.detail.expandedKeys;
sync();
});
sync();
</script>Disabled & Read-Only
Section titled “Disabled & Read-Only”Disabled items preserve legible muted ink while preventing activation; readOnly locks selection while allowing keyboard navigation and branch toggling.
<div class="grid w-full max-w-2xl gap-4 sm:grid-cols-2">
<proto-ui-liquid-glass-tree-root id="disabled-tree">
<div class="flex items-center gap-1">
<proto-ui-liquid-glass-tree-toggle data-toggle="packages">
<span aria-hidden="true">▾</span>
<span class="sr-only">Toggle packages</span>
</proto-ui-liquid-glass-tree-toggle>
<proto-ui-liquid-glass-tree-item
data-node="packages"
class="flex-1"
>
packages/
</proto-ui-liquid-glass-tree-item>
</div>
<proto-ui-liquid-glass-tree-group data-group="packages">
<proto-ui-liquid-glass-tree-item data-node="active">
core
</proto-ui-liquid-glass-tree-item>
<proto-ui-liquid-glass-tree-item data-node="deprecated">
legacy (disabled)
</proto-ui-liquid-glass-tree-item>
</proto-ui-liquid-glass-tree-group>
<proto-ui-liquid-glass-tree-item data-node="license">
LICENSE
</proto-ui-liquid-glass-tree-item>
</proto-ui-liquid-glass-tree-root>
<proto-ui-liquid-glass-tree-root id="readonly-tree">
<div class="flex items-center gap-1">
<proto-ui-liquid-glass-tree-toggle data-toggle="docs">
<span aria-hidden="true">▾</span>
<span class="sr-only">Toggle docs</span>
</proto-ui-liquid-glass-tree-toggle>
<proto-ui-liquid-glass-tree-item
data-node="docs"
class="flex-1"
>
docs/
</proto-ui-liquid-glass-tree-item>
</div>
<proto-ui-liquid-glass-tree-group data-group="docs">
<proto-ui-liquid-glass-tree-item data-node="overview">
overview.mdx
</proto-ui-liquid-glass-tree-item>
<proto-ui-liquid-glass-tree-item data-node="api">
api.mdx
</proto-ui-liquid-glass-tree-item>
</proto-ui-liquid-glass-tree-group>
</proto-ui-liquid-glass-tree-root>
</div>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const disabledTree = document.querySelector('#disabled-tree');
setElementProps(disabledTree, {
defaultValue: 'active',
defaultExpandedKeys: ['packages'],
});
setElementProps(
disabledTree.querySelector('[data-node="packages"]'),
{ nodeKey: 'packages', textValue: 'packages' }
);
setElementProps(
disabledTree.querySelector('[data-toggle="packages"]'),
{ nodeKey: 'packages', size: 'icon' }
);
setElementProps(
disabledTree.querySelector('[data-group="packages"]'),
{ nodeKey: 'packages' }
);
setElementProps(
disabledTree.querySelector('[data-node="active"]'),
{ nodeKey: 'active', parentKey: 'packages', textValue: 'core' }
);
setElementProps(
disabledTree.querySelector('[data-node="deprecated"]'),
{
nodeKey: 'deprecated',
parentKey: 'packages',
textValue: 'legacy',
disabled: true,
}
);
setElementProps(
disabledTree.querySelector('[data-node="license"]'),
{ nodeKey: 'license', textValue: 'LICENSE' }
);
const readonlyTree = document.querySelector('#readonly-tree');
setElementProps(readonlyTree, {
readOnly: true,
defaultValue: 'overview',
defaultExpandedKeys: ['docs'],
});
setElementProps(
readonlyTree.querySelector('[data-node="docs"]'),
{ nodeKey: 'docs', textValue: 'docs' }
);
setElementProps(
readonlyTree.querySelector('[data-toggle="docs"]'),
{ nodeKey: 'docs', size: 'icon' }
);
setElementProps(
readonlyTree.querySelector('[data-group="docs"]'),
{ nodeKey: 'docs' }
);
setElementProps(
readonlyTree.querySelector('[data-node="overview"]'),
{
nodeKey: 'overview',
parentKey: 'docs',
textValue: 'overview.mdx',
}
);
setElementProps(readonlyTree.querySelector('[data-node="api"]'), {
nodeKey: 'api',
parentKey: 'docs',
textValue: 'api.mdx',
});
</script>Right-to-Left (RTL)
Section titled “Right-to-Left (RTL)”Set direction="rtl" on Root to mirror group guides and horizontal arrow navigation.
<proto-ui-liquid-glass-tree-root
id="rtl-tree"
class="w-full max-w-sm"
>
<div class="flex items-center gap-1">
<proto-ui-liquid-glass-tree-toggle data-toggle="project">
<span aria-hidden="true">▾</span>
<span class="sr-only">تبديل مجلد المشروع</span>
</proto-ui-liquid-glass-tree-toggle>
<proto-ui-liquid-glass-tree-item
data-node="project"
class="flex-1"
>
المشروع
</proto-ui-liquid-glass-tree-item>
</div>
<proto-ui-liquid-glass-tree-group data-group="project">
<proto-ui-liquid-glass-tree-item data-node="components">
المكونات
</proto-ui-liquid-glass-tree-item>
<proto-ui-liquid-glass-tree-item data-node="styles">
الأنماط
</proto-ui-liquid-glass-tree-item>
</proto-ui-liquid-glass-tree-group>
<proto-ui-liquid-glass-tree-item data-node="readme">
الدليل
</proto-ui-liquid-glass-tree-item>
</proto-ui-liquid-glass-tree-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector('#rtl-tree');
setElementProps(root, {
direction: 'rtl',
defaultValue: 'components',
defaultExpandedKeys: ['project'],
});
setElementProps(root.querySelector('[data-node="project"]'), {
nodeKey: 'project',
textValue: 'المشروع',
});
setElementProps(root.querySelector('[data-toggle="project"]'), {
nodeKey: 'project',
size: 'icon',
});
setElementProps(root.querySelector('[data-group="project"]'), {
nodeKey: 'project',
});
setElementProps(root.querySelector('[data-node="components"]'), {
nodeKey: 'components',
parentKey: 'project',
textValue: 'المكونات',
});
setElementProps(root.querySelector('[data-node="styles"]'), {
nodeKey: 'styles',
parentKey: 'project',
textValue: 'الأنماط',
});
setElementProps(root.querySelector('[data-node="readme"]'), {
nodeKey: 'readme',
textValue: 'الدليل',
});
</script>| Prop | Type | Default |
|---|---|---|
value | string | undefined (controlled) |
defaultValue | string | '' |
expandedKeys | readonly string[] | undefined (controlled) |
defaultExpandedKeys | readonly string[] | [] |
direction | 'ltr' 'rtl' | ltr |
disabled | boolean | false |
readOnly | boolean | false |
a11yLabel | string | Tree |
Item, Group & Toggle
Section titled “Item, Group & Toggle”| Prop | Type | Default |
|---|---|---|
Item.nodeKey | string | '' |
Item.parentKey | string | '' |
Item.textValue | string | '' |
Item.disabled | boolean | false |
Group.nodeKey | string | '' |
Toggle.nodeKey | string | '' |
Toggle.size | 'default' 'icon' | default |
Toggle.disabled | boolean | false |
Events & Methods (Root)
Section titled “Events & Methods (Root)”| Name | Signature / Payload | Description |
|---|---|---|
valueChange | { value: string } | Emitted when a selection change is requested |
expandedChange | { expandedKeys: string[] } | Emitted when branch expansion changes are requested |
getTree | () => TreeEntry[] | Returns the current validated tree snapshot |
getExpandedKeys | () => string[] | Returns the list of expanded branch keys |
requestValue | (key: string) => boolean | Programmatically requests selecting a node |
requestExpanded | (key: string, open: boolean) => boolean | Programmatically requests expanding or collapsing a branch |
refresh | () => void | Recomputes and publishes the tree hierarchy snapshot |