<cs-tree-item>
StableNavigationSince 0.1

Tree items represent a single hierarchical node inside a tree, and can contain nested items that expand and collapse.

This component must be used as a child of <cs-tree>. Please see the Tree docs to see examples of this component in action.

API

Importing

If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick this component, use one of the following snippets.

npm Self-Hosted React
import '@cruglobal/cornerstone-components/components/tree-item/tree-item.js';
import './cornerstone/components/tree-item/tree-item.js';
import CsTreeItem from '@cruglobal/cornerstone-components/react/tree-item/index.js';

Slots

Learn more about using slots.

NameDescription
(default)The default slot.
collapse-iconThe icon to show when the tree item is collapsed.
expand-iconThe icon to show when the tree item is expanded.

Attributes & Properties

Learn more about attributes and properties.

PropertyAttributeDescriptionTypeDefaultReflects
disableddisabledDisables the tree item.booleanfalseYes
expandedexpandedExpands the tree item.booleanfalseYes
lazylazyEnables lazy loading behavior.booleanfalseYes
selectedselectedDraws the tree item in a selected state.booleanfalseYes

Methods

Learn more about methods.

NameDescriptionArguments
getChildrenItems()Gets all the nested tree items in this node.{ includeDisabled = true }: { includeDisabled?: boolean }

Events

Learn more about events.

NameDescription
cs-after-collapseEmitted after the tree item collapses and all animations are complete.
cs-after-expandEmitted after the tree item expands and all animations are complete.
cs-collapseEmitted when the tree item collapses.
cs-expandEmitted when the tree item expands.
cs-lazy-changeEmitted when the tree item's lazy state changes.
cs-lazy-loadEmitted when a lazy item is selected. Use this event to asynchronously load data and append items to the tree before expanding. After appending new items, remove the lazy attribute to remove the loading state and update the tree.

CSS Custom Properties

Learn more about CSS custom properties.

NameDescriptionDefault
--hide-durationThe animation duration when collapsing tree items.var(--cs-transition-normal)
--show-durationThe animation duration when expanding tree items.var(--cs-transition-normal)

Custom States

Learn more about custom states.

NameDescriptionCSS selector
disabledApplied when the tree item is disabled.:state(disabled)
expandedApplied when the tree item is expanded.:state(expanded)
indeterminateApplied when the selection is indeterminate.:state(indeterminate)
selectedApplied when the tree item is selected.:state(selected)

CSS Parts

Learn more about CSS parts.

NameDescriptionCSS selector
checkboxThe checkbox that shows when using multiselect.::part(checkbox)
checkbox__checkboxThe checkbox's exported checkbox part.::part(checkbox__checkbox)
checkbox__checked-iconThe checkbox's exported checked-icon part.::part(checkbox__checked-icon)
checkbox__controlThe checkbox's exported control part.::part(checkbox__control)
checkbox__indeterminate-iconThe checkbox's exported indeterminate-icon part.::part(checkbox__indeterminate-icon)
checkbox__labelThe checkbox's exported label part.::part(checkbox__label)
childrenThe container that wraps the tree item's nested children.::part(children)
expand-buttonThe container that wraps the tree item's expand button and spinner.::part(expand-button)
indentationThe tree item's indentation container.::part(indentation)
itemThe tree item's container. This element wraps everything except slotted tree item children.::part(item)
labelThe tree item's label.::part(label)
spinnerThe spinner that shows when a lazy tree item is in the loading state.::part(spinner)
spinner__spinnerThe spinner's exported spinner part.::part(spinner__spinner)
tree-itemThe component's outer wrapper.::part(tree-item)

Dependencies

This component automatically imports the following elements. Sub-dependencies, if any exist, are included in this list.