hierarchyInput: Hierarchical tree input for Shiny

View source: R/hierarchyInput.R

hierarchyInputR Documentation

Hierarchical tree input for Shiny

Description

Creates a hierarchical slicer-style input similar to a Power BI date hierarchy. The input value is a structured object (schema version 1) with resolved, rollup, explicit, and summary fields.

Usage

hierarchyInput(
  inputId,
  label = NULL,
  data,
  levels,
  selected = NULL,
  expanded = NULL,
  placeholder = "Selección múltiple",
  display = c("inline", "dropdown"),
  search = FALSE,
  searchPlaceholder = "Buscar...",
  selectAll = TRUE,
  selectAllLabel = "Seleccionar todo",
  expand = c("first", "all", "none"),
  width = "100%",
  height = "360px"
)

Arguments

inputId

The input slot that will be used to access the value.

label

Optional label displayed above the component.

data

A data frame containing the hierarchy columns.

levels

Character vector with column names, ordered from highest to lowest hierarchy level.

selected

Optional character vector of node ids to select initially.

expanded

Optional character vector of node ids to expand initially.

placeholder

Text shown when nothing is selected.

display

Visual presentation: "inline" keeps the tree visible, while "dropdown" opens it in a floating panel.

search

Whether to show a search box above the tree.

searchPlaceholder

Placeholder for the search field.

selectAll

Whether to show the select-all row.

selectAllLabel

Label for the select-all control.

expand

Initial expansion mode: first level, all levels, or none.

width

CSS width of the component.

height

CSS max-height of the tree area.

Details

The value received from the browser is user-controlled and must not be used as an authorization mechanism. Applications that filter sensitive data must validate selected ids against the server-side hierarchy and permissions.

Value

A Shiny HTML object.


shinyHierarchy documentation built on Oct. 2, 2026, 5:09 p.m.