Markupless Documentation - v0.4.3
    Preparing search index...

    Represents a generic text-containing element.

    Hierarchy (View Summary)

    Index

    Constructors

    Methods

    • Applies "Magic" argument processing. Infers intent based on argument types.

      Parameters

      • args: any[]

        Variadic arguments.

      Returns this

      The element instance.

    • Sets an HTML attribute.

      Parameters

      • name: string

        The attribute name.

      • value: string

        The attribute value.

      Returns this

      The element instance for chaining.

    • Adds a CSS class name to the element.

      Parameters

      • className: string

        The class name(s) to add.

      Returns this

      The element instance for chaining.

    • Renders a list of items reactively.

      Type Parameters

      • T

      Parameters

      • dataSource: State<T[]> | (() => T[])

        A State array or a function returning an array.

      • renderer: (item: T, index: number) => BaseElement

        Function to create a BaseElement for each item.

      Returns this

      The element instance for chaining.

      ul().each(tasksState, (task) => li(task));
      
    • Attaches an event listener to the element.

      Type Parameters

      • K extends keyof HTMLElementEventMap

      Parameters

      • eventName: K

        The event name (e.g., "click").

      • handler: (event: HTMLElementEventMap[K]) => void

        The event handler function.

      Returns this

      The element instance for chaining.

    • Renders the element into a DOM node.

      Returns HTMLElement

      The created HTMLElement.

      Error if called outside of a browser environment.

    • Applies inline styles to the element.

      Parameters

      • styles: Partial<CSSStyleDeclaration>

        Object containing CSS properties.

      Returns this

      The element instance for chaining.

      div().style({ color: "red", fontSize: "16px" });
      
    • Sets the text content of the element. Supports reactive state binding.

      Parameters

      • content: string | number | State<string | number> | (() => string | number)

        String, number, reactive State, or getter function.

      Returns this

      The element instance for chaining.

      div().text("Static Text");
      div().text(myState); // Updates automatically