Talisman LogoTalisman Logo Design System
Browse documentation
Components

Document tree combobox

A searchable selector that lets people pick one document from nested folders, with metadata and a responsive selected path.

Stableimport { DocumentTreeCombobox } from "@repo/ui/document-tree-combobox";Source

Open the field, type to search or use the arrow keys to move through folders. Only documents can be selected. Folders open and close.

When to use

  • To pick one document from a collection grouped in folders, such as autos, subsídios and contracts.
  • When people recognize a document by its folder or file name, so the path helps.
  • When the list is too long for a flat Select.

When not to use

  • A flat list. Use a Combobox or a Select.
  • Choosing several documents. Use the multiple selector.
  • Browsing a hierarchy with actions on each node. Use a Tree view.

States

Selected path

With showSelectedPath the trigger shows the whole path when it fits and shortens it from the left when the field is narrow. The leaf is always visible.

Disabled

Examples

Metadata and a pinned shortcut

A node can carry a description and details. Both are searchable and are announced to screen readers. separatorAfter draws a divider below a pinned node.

Content

  • ariaLabel names the field and the tree: “Documento de referência”.
  • placeholder says what to pick: “Selecione um documento”.
  • emptyMessage explains the empty search: “Nenhum documento encontrado.”
  • Use the file name as description when labels repeat across folders.
  • Pass every string from the app. The component has no built-in copy.

Accessibility

  • The trigger is a button with role="combobox", aria-haspopup="tree", aria-expanded and aria-controls. Its name combines ariaLabel and the selected path.
  • The list is a WAI-ARIA tree: role="tree" and role="treeitem" with aria-level, aria-posinset, aria-setsize and aria-expanded on folders. Documents set aria-selected.
  • ArrowDown and ArrowUp move between visible nodes. Home and End go to the first and last. ArrowRight opens a folder or enters it, ArrowLeft closes it or goes to the parent. Enter or Space selects a document or toggles a folder.
  • Focus moves to the search input when the popover opens. ArrowDown in the search moves into the tree. Typing a character in the tree sends it to the search.
  • While searching, folders with matches stay open and matching text is highlighted. The empty message has role="status".
  • Matching ignores accents and case.

Code

import { DocumentTreeCombobox } from "@repo/ui/document-tree-combobox";
import type { DocumentTreeComboboxNode } from "@repo/ui/document-tree-combobox";

const nodes: DocumentTreeComboboxNode[] = [
  {
    children: [
      {
        description: "contestacao.pdf",
        id: "contestacao",
        label: "Contestação",
        value: "contestacao",
      },
    ],
    id: "autos",
    label: "Autos do processo",
  },
];

<DocumentTreeCombobox
  ariaLabel="Documento de referência"
  emptyMessage="Nenhum documento encontrado."
  name="documento"
  nodes={nodes}
  onValueChange={setValue}
  placeholder="Selecione um documento"
  searchPlaceholder="Buscar documento"
  value={value}
/>;

Props

DocumentTreeCombobox
PropTypeDefaultDescription
ariaLabelstring—Accessible name of the trigger and the tree
disabledbooleanfalsePrevents opening and changing the selection
emptyMessagestring—Message shown when no node matches the search
namestring—Name of the hidden input used for form submission
placeholderstring—Text of the trigger when nothing is selected
searchPlaceholderstring—Placeholder and accessible name of the search input
showSelectedPathbooleanfalseShows the selected path in the trigger when it fits; otherwise shows only the leaf
More props
PropTypeDefaultDescription
nodesDocumentTreeComboboxNode[]—Folders and documents. The component renders nothing when the list is empty.
valuestring—Selected document value, when the caller controls it.
defaultValuestring""Initial value when the component keeps its own state.
onValueChange(value: string) => void—Called when a document is selected.
classNamestring—Layout classes for the trigger.
listClassNamestring—Layout classes for the scrollable tree.
refRef<HTMLButtonElement>—Ref of the trigger.
DocumentTreeComboboxNode
PropTypeDefaultDescription
idstring—Unique identifier of the node.
labelstring—Searchable name of the folder or document.
valuestring—Value of a selectable document. Folders have none.
childrenDocumentTreeComboboxNode[]—Nested nodes. A node with children is a folder.
displayLabelstring—Shorter label shown in the tree and the trigger.
descriptionstring—Secondary searchable text, such as the file name.
details{ label: string; value: string }[]—Searchable metadata shown under the label.
iconReactNode—Decorative icon shown before a document label.
searchTextstring—Hidden aliases used only by the search.
separatorAfterboolean—Draws a divider below the node unless it is the last in its list.

Known issues

Issue Effect
Rows use hover:bg-disabled for the hover state. A disabled-state token styles an interactive hover, which can look unavailable.
The trigger caret uses opacity-50. Opacity lowers the icon contrast.
Rows have a min-h-8 (32px) height with no touch variant. Meets the 24px desktop minimum, but is small on touch screens.
A node with value set and children is a folder that cannot be selected. Easy to configure by mistake: the value is silently ignored.
Edit this page on GitHub