Skip to main content
The Nested Select component allows users to select options from a hierarchical tree structure with expandable categories and subcategories.

Basic usage

<flx-nested-select
  [options]="nestedOptions"
  [(ngModel)]="selectedValue">
</flx-nested-select>

Properties

options
NestedOption[]
required
Hierarchical array of options
value
any
Currently selected value
placeholder
string
default:"Select an option"
Placeholder text when nothing is selected
searchable
boolean
default:"true"
Enable search/filter functionality
expandable
boolean
default:"true"
Allow expanding/collapsing of categories
showPath
boolean
default:"true"
Show full path of selected item (e.g., “Category > Subcategory > Item”)
disabled
boolean
default:"false"
Disables the component

NestedOption interface

interface NestedOption {
  value: any;
  label: string;
  icon?: string;
  disabled?: boolean;
  children?: NestedOption[];
}

Events

valueChange
EventEmitter<any>
Emitted when selection changes
expand
EventEmitter<NestedOption>
Emitted when a category is expanded
collapse
EventEmitter<NestedOption>
Emitted when a category is collapsed

Examples

<flx-nested-select
  label="Category"
  [(ngModel)]="selectedCategory"
  [options]="categories">
</flx-nested-select>
export class CategorySelector {
  selectedCategory: string;
  categories = [
    {
      value: 'electronics',
      label: 'Electronics',
      children: [
        {
          value: 'computers',
          label: 'Computers',
          children: [
            { value: 'laptops', label: 'Laptops' },
            { value: 'desktops', label: 'Desktops' },
            { value: 'tablets', label: 'Tablets' }
          ]
        },
        {
          value: 'phones',
          label: 'Phones',
          children: [
            { value: 'smartphones', label: 'Smartphones' },
            { value: 'feature-phones', label: 'Feature Phones' }
          ]
        }
      ]
    },
    {
      value: 'clothing',
      label: 'Clothing',
      children: [
        {
          value: 'mens',
          label: "Men's Clothing",
          children: [
            { value: 'shirts', label: 'Shirts' },
            { value: 'pants', label: 'Pants' },
            { value: 'shoes', label: 'Shoes' }
          ]
        },
        {
          value: 'womens',
          label: "Women's Clothing",
          children: [
            { value: 'dresses', label: 'Dresses' },
            { value: 'tops', label: 'Tops' },
            { value: 'skirts', label: 'Skirts' }
          ]
        }
      ]
    }
  ];
}

Styling

flx-nested-select {
  --flx-nested-select-indent: 20px;
  --flx-nested-select-item-padding: 8px 12px;
  --flx-nested-select-hover-background: #f3f4f6;
  --flx-nested-select-selected-background: #dbeafe;
  --flx-nested-select-expand-icon-size: 16px;
  --flx-nested-select-max-height: 400px;
}

Accessibility

The Nested Select component ensures accessibility:
  • role="tree" with role="treeitem" for hierarchy
  • Arrow keys for navigation (up/down, left/right for expand/collapse)
  • aria-expanded for expandable items
  • aria-selected for selected items
  • Keyboard shortcuts (Enter to select, Space to expand)
  • Screen reader announcements

Best practices

  • Keep hierarchy depth to 3-4 levels maximum
  • Use clear, descriptive labels at each level
  • Enable search for large hierarchies
  • Show the full path of selected items for clarity
  • Group related items logically
  • Consider alphabetical or logical ordering
  • Provide visual feedback for expandable items
  • Allow keyboard navigation
For deep hierarchies with many options, enable searchable to help users find items quickly without navigating through multiple levels.

Build docs developers (and LLMs) love