Skip to content

UseCreateElement

katanakit-js / useCreateElement

function useCreateElement<T>(tagName, options?): HTMLElementTagNameMap[T];

Defined in: infrastructure/dom/dom.service.ts:392

Creates a new HTML element.

Type Parameter Description
T extends keyof HTMLElementTagNameMap The tag name from HTMLElementTagNameMap.
Parameter Type Description
tagName T The tag name to create.
options? ElementCreationOptions Optional element creation options.

HTMLElementTagNameMap[T]

The newly created element.

If called outside a browser environment.

const div = useCreateElement("div");
const input = useCreateElement("input", { is: "custom-input" });