tsuite
    Preparing search index...

    Function hugText

    • Shrinks the width of the given HTML element(s) until the text wraps to a new line, then restores the width to the minimum value that fits the text on a single line.

      This function is useful for "hugging" text content by reducing the element's width to the smallest possible value before the content overflows or wraps.

      Parameters

      • input: HTMLElement | HTMLCollection | NodeList | HTMLElement[]

        The target element(s) to adjust. Accepts a single HTMLElement, a NodeList, an HTMLCollection, or an array of HTMLElements.

      Returns void

      If the input is not provided or is not a valid type.

      const element = document.getElementById('my-text');
      hugText(element);