Websites v4 docs v5.2.4
    Preparing search index...

    Function useDynamicMenuItems

    • Hook that dynamically updates how many menu items are visible in a navbar based on the screen size / container width and the collective width of the menu items in the DOM + the size of the gap between them.

      Parameters

      • __namedParameters: {
            debounceInterval?: number;
            gapWidth: number;
            menuItems: MenuItem[];
            moreButtonWidth: number;
        }

      Returns UseDynamicMenuItems

      const {
      visibleItems,
      overflowItems,
      containerRef,
      menuItemRefs
      } = useDynamicMenuItems({ menuItems, gapWidth: 20, moreButtonWidth: 72 });

      ...

      return (
      <div ref={containerRef}>
      {visibleItems.map((item, index) => (
      <div ref={(el) => {
      menuItemRefs.current[index] = el;
      }}
      >
      {item.name}
      </div>
      ))}
      </div>
      )