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 Select

A Select whose dropdown is a tree of expandable groups, where only the leaves can be chosen.

ComponentsTree Select
inputinteractive
<arc-tree-select>

Overview

TreeSelect has the trigger of Select and a tree in its panel. The dropdown shows groups that expand, and the leaves inside them are the choices. The trigger shows the chosen leaf after a muted path of its ancestors, so "Violin" reads as "Strings / Violin". Only leaves can be selected. A node with children is a group header that expands and collapses but can't be chosen, so the submitted value is always a single leaf. When the panel opens, the branches containing the current value expand, so the selection is in view. TreeSelect follows the ARIA combobox pattern with a tree popup. Enter, Space or an arrow key opens the panel. Arrow Up and Down move between rows, Arrow Right and Left expand and collapse groups, Enter picks a leaf and Escape closes. Typing jumps to the row that starts with those letters, as in Select. It takes part in native forms through ElementInternals and submits the selected leaf's value under its `name`.

Guidelines

Do

  • Use it when the options have a real hierarchy that readers think in, such as instrument families, product categories or folder trees
  • Give every node a stable value, group headers included. Group values drive `expanded-values` and appear in the `path` of `arc-change`
  • Keep the tree to two or three levels. A deeper tree belongs in a picker dialog
  • Use `expanded-values` to open the branches readers need most
  • Set a visible `label`. It's also the accessible name
  • Disable a node that's temporarily unavailable instead of removing it, so the structure stays recognizable

Don't

  • Don't use it for a flat list. Use Select
  • Don't use it when readers need to type to filter a large set. Use Combobox, whose text field takes the keystrokes
  • Don't use it for browsing or navigation outside a form. Use TreeView, a standalone tree with no trigger or form value
  • Don't expect group headers to be selectable. If a branch must be a valid choice, add a leaf such as "All strings" inside it

Features

  • `expanded-values` lists the groups to show expanded at first
  • Disabled nodes render, but the keyboard skips them and they can't be selected. A disabled group hides its children
  • Supports `required` validation
  • Neutral rails show nesting depth and carry no state

Preview

Usage

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

<script type="module" src="@arclux/arc-ui"></script>

<arc-tree-select
  label="Instrument"
  name="instrument"
  placeholder="Pick an instrument..."
></arc-tree-select>

<script>
  const treeSelect = document.querySelector('arc-tree-select');

  // items is a property, not an attribute: assign the tree from script.
  treeSelect.items = [
    { value: 'keys', label: 'Keys', children: [
      { value: 'grand-piano', label: 'Grand Piano' },
      { value: 'rhodes', label: 'Rhodes' },
    ] },
    { value: 'strings', label: 'Strings', children: [
      { value: 'violin', label: 'Violin' },
      { value: 'cello', label: 'Cello' },
    ] },
    { value: 'percussion', label: 'Percussion', children: [
      { value: 'timpani', label: 'Timpani' },
    ] },
  ];

  // Pre-expand a branch, or let auto-expand follow the selected value.
  treeSelect.expandedValues = ['strings'];

  treeSelect.addEventListener('arc-change', (e) => {
    // e.detail.path holds the ancestor group values, root first.
    console.log('Selected:', e.detail.value, 'in', e.detail.path.join(' / '));
  });
</script>

API

valuestring''
The selected leaf's value. Setting it programmatically updates the trigger's breadcrumb label, and the branches containing it auto-expand the next time the panel opens.
placeholderstring'Select...'
Hint text displayed inside the trigger when no leaf is selected. It disappears once a value is chosen.
labelstring''
Visible label rendered above the trigger. Also serves as the accessible name. Always provide one for accessibility compliance.
namestring''
Form field name submitted with the selected leaf value via ElementInternals.
disabledbooleanfalse
When true, the trigger becomes non-interactive: it cannot be opened, focused, or clicked, and renders with reduced opacity.
errorstring''
Error message displayed below the trigger. When set, the trigger border turns red.
itemsArray<{value: string, label: string, children?: Array<object>, disabled?: boolean}>[]
Recursive tree of nodes. A node with a non-empty children array is a group header: it expands and collapses but can never be selected. A node without children is a selectable leaf. disabled nodes render but cannot be reached by keyboard or selected, and a disabled group hides its children.
expandedValuesstring[][]
Values of group nodes to render initially expanded. Attribute: expanded-values (JSON array). Branches containing the selected value auto-expand on open regardless of this list.
size'sm' | 'md' | 'lg''md'
Controls the trigger size.
openbooleanfalse
Controls whether the tree panel is visible. Automatically set to false when a leaf is selected, Escape is pressed, or the user clicks outside. Held at false while disabled.
formAssociatedbooleantrue
propertiesobject{ // flag(), unlike `disabled`. The exclusion in props.js is specifically // about form-associated *platform* semantics: a `disabled` content // attribute that is merely present makes the element actually disabled // per the HTML spec, and formDisabledCallback assigns the property back, // so no converter can win. Neither of these is platform-mapped: // `required` is enforced by _computeValidity() below and `readonly` by // each component's own interaction handlers, so the stock converter buys // nothing here and costs the usual bug: `required="false"` read as true, // blocking submission of a form the author meant to leave optional. // Finding #48's shape, across all 26 form controls at once. required: flag(false), readonly: flag(false), }
Lit merges static properties up the prototype chain, so every consumer gets these without declaring them. required participates in constraint validation below; readonly reflects for styling and is enforced by each component's interaction handlers (the mixin can't know which gestures mutate state).
autoValidatesbooleantrue
Components that run their own constraint-validation logic (pattern checks, range checks) opt out of the automatic required sync by overriding this to false, and own the whole validity flag set instead.
form
validity
validationMessage
requiredbooleanfalse
readonlybooleanfalse

Methods

checkValidity()boolean
Whether the control currently satisfies its constraints, per the native constraint-validation API. Fires invalid on the element when it does not, and reports nothing to the user.
reportValidity()boolean
As checkValidity(), but also shows the browser's validation message against the control when it fails.

Events

arc-change
Fired when a leaf is selected. detail.value is the leaf value, detail.label its label, and detail.path the array of ancestor group values from root to parent.

See also