Getting startedComponentsDesign tokensThemingTheme synthesizerFrameworksAccessibilityUtilitiesServer renderingBrowser supportContributingChangelogApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip
ARC UIARC Radiant Components
v4.9DocsComponentsTokensSynthesizer
Getting startedFrameworksServer renderingDesign tokensThemingTheme synthesizerTypographyUtilitiesAll componentsAccessibilityBrowser supportChangelogContributingStatsApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip

Tree View

Shows nested items as a tree whose branches open and close, with one selected item at a time.

ComponentsTree View
navigationinteractive
<arc-tree-view>

Overview

TreeView shows nested data as a tree whose branches open and close, such as a file browser, a navigation menu or a documentation outline. Each node is an `<arc-tree-item>`, nested to any depth, with a `label`, an optional `icon` (rendered as text) and an `expanded` attribute for its starting state. Clicking a branch selects it and opens or closes it. Clicking a leaf selects it. The selected row is tinted and drawn in `--interactive`, a vertical guide line runs beside each nested group, and the chevron turns as a branch opens or closes. ArrowDown and ArrowUp move between visible rows, ArrowRight opens a branch, ArrowLeft closes it, and Enter or Space selects. Home, End and typeahead from the WAI-ARIA tree pattern aren't supported, and ArrowRight and ArrowLeft don't move to a child or back to the parent. `arc-select` fires with the item and its `path`, the chain of labels from the root, and `arc-toggle` fires when a branch opens or closes.

Guidelines

Do

  • Give every node a descriptive `label`
  • Set `expanded` on the top-level branches readers should see first
  • Add an `icon` when readers scan by type, such as folder and file glyphs in a file browser
  • Listen to `arc-select` to update the main content when a node is picked
  • Keep the tree to three or four levels. Deeper trees are hard to scan

Don't

  • Don't use it for flat lists. Use List or NavigationMenu
  • Don't load hundreds of top-level nodes at once. Load them in pages or on demand
  • Don't use it to select several items. It tracks one selection
  • Don't rely on icons alone. Every item needs a text label
  • Don't use very long labels. They truncate and can't be read in full

Features

  • Roles `tree`, `treeitem` and `group`, with `aria-expanded` on branches
  • Guide lines are drawn in `--divider`
  • Long labels truncate with an ellipsis

Preview

Usage

This component needs JavaScript. Use the Web Component or a framework wrapper.

<arc-tree-view>
  <arc-tree-item label="src" icon="πŸ“" expanded>
    <arc-tree-item label="index.ts" icon="πŸ“„"></arc-tree-item>
  </arc-tree-item>
  <arc-tree-item label="package.json" icon="πŸ“„"></arc-tree-item>
</arc-tree-view>

Events

arc-toggledetail:{ item: { label: string, icon: string }, path: string[], expanded: boolean }
Fired when a tree node is expanded or collapsed. path is the node's label chain from the root and is what identifies it: two nodes may share a label.
arc-selectdetail:{ value: string, item: { label: string, icon: string }, path: string[] }
Fired when a tree item is selected. path is the node's label chain from the root, matching arc-toggle.

TreeItem

<arc-tree-item>

Node within a TreeView. Can nest for sub-trees.

items
Nested arc-tree-item children
hasChildren
labelstring''
Item label text
iconstring''
Icon or emoji
expandedbooleanfalse
Expand child items

See also