Skip to main content

sp-org-chart

Hierarchical org chart web component with drag-and-drop reorganization, search/filter, user selection, and full keyboard navigation support. Pass an array of user objects via the users property; the component builds the hierarchy automatically from reportsTo relationships.

Installation

Install from a GitHub Release:

npm install https://github.com/StephanWald/trm-ai-webcomponents/releases/download/v0.0.1/skillspilot-webcomponents-0.0.1.tgz

Or load via script tag:

<script type="module" src="https://stephanwald.github.io/trm-ai-webcomponents/wc/skillspilot.esm.js"></script>

Examples

Basic Org Chart

A flat user array with reportsTo relationships. The component builds the hierarchy automatically.

View / Edit Source

Editable Mode

Enable drag-and-drop reorganization with editable="true". Users can long-press (500ms) on a tile and drag it to a new manager.

View / Edit Source

Filtered View

Use the search input to filter users by name, title, or department. Filtered results show the full ancestor chain so context is preserved.

View / Edit Source

Event Handling

Listen to user-click, user-dblclick, user-delete, and hierarchy-change events emitted by the component.

View / Edit Source

Dark Mode

Apply the theme-dark class (or set the theme attribute) to switch to the dark color scheme using DWC design tokens.

View / Edit Source

API Reference

Properties

PropertyAttributeTypeDefaultDescription
editableeditablebooleantrueEnable/disable edit mode for drag-and-drop and deletion
filterBranchIdfilter-branch-idstring''Branch ID to filter by when filterMode is not 'none'
filterModefilter-mode"highlight" | "isolate" | "none"'none'Branch filter mode — 'none' shows all, 'highlight' dims non-matching, 'isolate' hides unrelated branches
noDataMessageno-data-messagestring'No data available'Custom message when users array is empty
themetheme"auto" | "dark" | "light"'auto'Theme override for standalone usage
usersUser[][]Flat array of users with reporting relationships

Events

EventDetail TypeDescription
hierarchyChangeHierarchyChangeDetailEmitted when hierarchy changes via drag-and-drop
userClickUserEventDetailEmitted when a user tile is clicked
userDblclickUserEventDetailEmitted when a user tile is double-clicked
userDeleteUserEventDetailEmitted when a user is deleted

Methods

MethodSignatureDescription
clearHighlight() => Promise<void>Clear all highlights
getSelected() => Promise<User | null>Get the currently selected user
highlightUser(userId: string) => Promise<void>Highlight a specific user by ID
scrollToUser(userId: string) => Promise<void>Scroll a user tile into view with smooth animation

CSS Custom Properties

PropertyDescription
--dwc-border-radiusBorder radius for user tiles and drop zones
--dwc-border-radius-fullFull (circular) border radius for user avatars
--dwc-border-radius-lgLarge border radius for the floating drop zones container
--dwc-border-radius-smSmall border radius for branch badge
--dwc-color-borderBorder color for tiles, children connector, and drop zones
--dwc-color-dangerDanger color for countdown ring and delete drop zone
--dwc-color-primaryAccent color for selected tile, avatar initials background, branch tile border
--dwc-color-primary-surfaceLight primary surface for branch badge background
--dwc-color-primary-textText color on primary-colored surfaces (avatar initials)
--dwc-color-surfaceBackground color for user tiles and drop zones
--dwc-color-surface-altAlternate surface for branch tiles
--dwc-color-textPrimary text color for user names
--dwc-color-text-secondarySecondary text color for role/email/phone labels
--dwc-color-warningWarning color for highlighted tile border
--dwc-font-familyBase font family for all text in the org chart
--dwc-font-size-baseBase font size for names and body text
--dwc-font-size-lgLarge font size for avatar initials and empty-state message
--dwc-font-size-smSmall font size for role labels and secondary text
--dwc-font-size-xsExtra-small font size for branch badge
--dwc-font-weight-mediumMedium weight for labels and badges
--dwc-font-weight-semiboldSemibold weight for user names
--dwc-line-height-normalNormal line height for body text
--dwc-shadow-mdMedium box shadow on hovered user tiles and drag preview
--dwc-shadow-smSmall box shadow on resting user tiles
--dwc-shadow-xlExtra-large box shadow on the floating drop zones container
--dwc-spacing-2xlDouble extra-large spacing for empty-state padding
--dwc-spacing-lgLarge spacing for drop zone gaps (20px default)
--dwc-spacing-mdMedium spacing for tile padding and container padding (12px default)
--dwc-spacing-smSmall spacing (8px default)
--dwc-spacing-xlExtra-large spacing for children indentation (32px default)
--dwc-spacing-xsExtra-small spacing (4px default)
--dwc-transition-fastFast transition duration for hover and drag states

CSS Parts

PartDescription
drop-zoneDrop zone for drag-and-drop
no-dataNo data message container
tree-containerMain tree container
user-tileIndividual user tile