Axon 911 Frontend DocsAxon 911 Frontend Docs
Axon 911 Frontend Docs
    Loading navigation…
U
User
Switch to light mode
  1. Components
  2. Tree
  3. API and Development

Tree

API and Development

View SourceOpens in a new tabSubmit IssueOpens in a new tab
Import Tree, TreeMode, TreeSelectionMode from @prepared911/ui/tree.
Tree
PropTypeDefaultNotes
itemsreadonly TreeItemData[]requiredRows. Ids are unique across the tree.
modeTreeModeDataData is a role="tree"; Navigation is nested lists.
selectionModeTreeSelectionModeSingleData mode only. None, Single or Multiple.
aria-label, aria-labelledbyLocalizedMessage, stringRequired in data mode: one of the two. Optional in navigation mode.
expandedreadonly string[]Controlled expanded ids.
defaultExpandedreadonly string[][]Initial expanded ids.
onExpandedChange(expanded, details) => voiddetails.reason is trigger-press, item-press or list-navigation. Cancelable.
selectedreadonly string[]Controlled selected ids. In navigation mode the one selected row is the current page.
defaultSelectedreadonly string[][]Initial selected ids.
onSelectedChange(selected, details) => voiddetails.reason is item-press. Cancelable.
onExpand(id: string) => voidA lazy row was expanded.
compactbooleanfalseIcons only, labels in Tooltips, no nested groups.
guidesbooleantrueConnector line beside nested groups.
disabledbooleanfalseDisables every row.
toggleLabelLocalizedMessageName of a disclosure button that sits beside a link row.
loadingLabelLocalizedMessageName of the skeleton row shown while children load.
className, id, refOn the root ul.
The tree takes no style.
TreeItemData
FieldTypeNotes
idstringUnique across the tree.
labelLocalizedMessage | DisplayValuePrimary text.
descriptionLocalizedMessage | DisplayValueSecondary text; the row's accessible description.
iconGlyphLead icon. Decorative.
counternumber | LocalizedMessage | DisplayValueResting small Counter.
badge{ text: LocalizedMessage; intent?: BadgeIntent }Small Badge.
status{ color: StatusDotColor; label: LocalizedMessage }StatusDot; label is read, not shown.
action{ glyph; label; onPress; disabled? }A trailing small ghost icon Button.
childrenreadonly TreeItemData[]Nested rows.
hasChildrenbooleanA parent whose children are not loaded yet.
loadingbooleanBusy, with a skeleton row in the group.
disabledbooleanSkipped by arrow keys and typeahead; cannot be selected, expanded or activated.
onClick(event) => voidActivation. preventDefaultBehavior() skips the tree's own selection and expansion.
href, external, newTabLabelA destination through Link. external requires newTabLabel.
Enums
  • TreeMode: Data, Navigation.
  • TreeSelectionMode: None, Single, Multiple.
Props
NameTypeDefaultDescription
itemsreadonly TreeItemData[]—The rows. Ids must be unique across the whole tree.
aria-labelLocalizedMessage—Accessible name of the tree. Accessible name of the tree, when the element alone is not enough. Name of the root list, when the landmark alone is not enough.
aria-labelledbystring—Id of an element that also names the tree. Id of the element that names the tree. Id of an element that names the root list.
classNamestring—Classes appended to the root list.
compactbooleanfalseShows only the top-level rows' lead icons, with each label in a Tooltip, and hides nested groups. A parent row stays as an icon and cannot expand. A row with no icon is left out.
defaultExpandedreadonly string[][]Ids of the rows expanded at first when expanded is not passed.
defaultSelectedreadonly string[][]Ids of the rows selected at first when selected is not passed.
disabledbooleanfalseDisables every row: none can be focused, selected, expanded or activated. A tree inside a disabled fieldset is disabled the same way.
expandedreadonly string[]—Controlled ids of the expanded rows.
guidesbooleantrueDraws a connector line beside each nested group.
idstring—Id of the root list.
loadingLabelLocalizedMessage—Accessible name of the skeleton row shown while a row's children load.
modeTreeMode—role="tree" semantics. Default. Nested lists with disclosure buttons and links.
onExpand((id: string) => void)—Called with a row's id when the row is expanded, is marked hasChildren, and has no children yet. Load the children and pass them back through items. It runs once per expansion, whether the change came from the user or from expanded.
onExpandedChangeTreeExpandedChangeHandler—Fires when a row asks to expand or collapse.
onSelectedChangeTreeSelectedChangeHandler—Fires when a row asks to be selected.
refRef<HTMLUListElement>—Ref to the root ul.
selectedreadonly string[]—Controlled ids of the selected rows. In navigation mode the one selected row is the current page.
selectionModeTreeSelectionModeTreeSelectionMode.SingleHow many rows can be selected.
toggleLabelLocalizedMessage—Accessible name of a disclosure control that is separate from its row, such as the toggle beside a link row in navigation mode. The row's label follows it, so the button reads, for example, "Toggle Reports".
Storybook
Interactive examples and edge cases for this component are in Storybook.
DefaultOpens in a new tab
Previous
Tree / Usage
Next
Tree / Accessibility
On this page
Tree
TreeItemData
Enums
Props
Storybook