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: Div

A 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.NavLink tree 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 with DashIconify).

  • "icon_color" (optional): CSS color value applied to the icon. When omitted,

    icons inherit currentColor from 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 to dmc.NavLink for 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 id string from the store value use:

Tree.ids.get_index_from_navlink_item_id(selected_item)
Parameters:
itemslist of dict

List of tree node definitions (see structure above).

selected_itemstr, optional

The id of the node that is highlighted on initial render.

default_iconstr, optional

Fallback icon value for nodes that do not specify an icon. Supports both local image/data-URI and Iconify values.

aio_idstr, optional

Unique identifier for this component instance. A UUID is generated when not provided.

IDs

class ansys.solutions.dash_super_components.Tree.TreeIds#

Bases: AIOIds

Provides IDs for the subcomponents of Tree.

Extract the aio_id from a navlink item ID dictionary.

Parameters:
navlink_item_iddict[str, Any]

The ID dictionary from which to extract the aio_id.

Returns:
str

The extracted aio_id.

Raises:
ValueError

If 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:
navlink_item_iddict[str, Any]

The ID dictionary from which to extract the index.

Returns:
str

The extracted index.

Raises:
ValueError

If the index is not found in the navlink item ID or if the ID is invalid.

Return the ID for a navlink item.

Parameters:
aio_idstr or _Wildcard

The component’s unique identifier.

indexstr, None, or _Wildcard

The unique index of the navlink item within the tree.

Returns:
dict[str, Any]

The unique ID dictionary for a navlink item subcomponent.

classmethod selected_item(aio_id: str | Wildcard) → dict[str, Any]#

Return the ID for the selected item store.

Parameters:
aio_idstr or _Wildcard

The component’s unique identifier.

Returns:
dict[str, Any]

The unique ID dictionary for the selected item store subcomponent.