UMD Web Utilities Library
    Preparing search index...

    Function createTextContainer

    • Creates a text container element with optional nested text element

      Creates a wrapper element (div by default) optionally containing a nested text element (paragraph by default). Useful for creating structured text blocks like summaries, descriptions, or content blocks.

      Parameters

      • text: {
            allowHTML?: boolean;
            containerTag?: keyof HTMLElementTagNameMap;
            text: string;
            textTag?: (keyof HTMLElementTagNameMap) | null;
        }

        The text content to display

      Returns HTMLElement | null

      Container element with text content, or null if text is empty

      // Default: div containing paragraph
      const summary = createTextContainer({
      text: 'This is a summary of the article content.'
      });
      // Result: <div><p>This is a summary...</p></div>

      // Direct text without nested element
      const directText = createTextContainer({
      text: 'Direct text content',
      textTag: null
      });
      // Result: <div>Direct text content</div>

      // Custom container and text tags
      const article = createTextContainer({
      text: 'Article content',
      containerTag: 'article',
      textTag: 'div'
      });
      // Result: <article><div>Article content</div></article>

      // With HTML content (use carefully)
      const richText = createTextContainer({
      text: '<strong>Bold</strong> text',
      allowHTML: true
      });