Tree#
- class ansys.solutions.dash_super_components.Tree(items: list[dict[str, Any]], selected_item: str | None = None, default_icon: str | None = None, aio_id: str | None = None)#
Bases:
DivA Dash component for creating nested hierarchical tree structures.
Tree is based on the Dash All-in-One (AIO) component pattern. It renders a multi-level
dmc.NavLinktree and is commonly used as a navigation sidebar.Interaction behavior is intentionally decoupled for parent nodes:
Clicking a row selects the node.
Clicking the dedicated expander control toggles open/closed state.
Each item dict supports the following keys:
"id"(required): unique string identifier for the node."text"(required): display label."icon"(optional): icon value for the item. Supports local image/data-URI/path values(rendered as a CSS-mask icon span) and Iconify names like
"mdi:user"(rendered withDashIconify).
"icon_color"(optional): CSS color value applied to the icon. When omitted,icons inherit
currentColorfrom the NavLink and follow active/dark-mode colors.
"icon_type"(optional): one of"auto"(default),"local", or"iconify". Use this to override auto-detection when needed.
"children"(optional): list of child item dicts (same structure)."expanded"(optional): bool — whether the node is expanded on load."disabled"(optional): bool — whether the node is non-interactive."description"(optional): secondary text shown below the label."styles"(optional): dict forwarded todmc.NavLinkfor per-item styling.
To access the currently selected item in a callback use:
Tree.ids.selected_item(aio_id) # Store; value is a dict with key "index" = item id
To resolve the item
idstring from the store value use:Tree.ids.get_index_from_navlink_item_id(selected_item)
- Parameters:
- items
listofdict List of tree node definitions (see structure above).
- selected_item
str,optional The
idof the node that is highlighted on initial render.- default_icon
str,optional Fallback icon value for nodes that do not specify an
icon. Supports both local image/data-URI and Iconify values.- aio_id
str,optional Unique identifier for this component instance. A UUID is generated when not provided.
- items
IDs
- class ansys.solutions.dash_super_components.Tree.TreeIds#
Bases:
AIOIdsProvides IDs for the subcomponents of
Tree.Extract the aio_id from a navlink item ID dictionary.
- Parameters:
- Returns:
strThe extracted aio_id.
- Raises:
ValueErrorIf the aio_id is not found in the navlink item ID or if the ID is invalid.
Extract the index from a navlink item ID dictionary.
- Parameters:
- Returns:
strThe extracted index.
- Raises:
ValueErrorIf the index is not found in the navlink item ID or if the ID is invalid.
Return the ID for a navlink item.