Skip to content
0

katanakit-js / useCreateElement

Function: useCreateElement() ​

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

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

Creates a new HTML element.

Type Parameters ​

Type ParameterDescription
T extends keyof HTMLElementTagNameMapThe tag name from HTMLElementTagNameMap.

Parameters ​

ParameterTypeDescription
tagNameTThe tag name to create.
options?ElementCreationOptionsOptional element creation options.

Returns ​

HTMLElementTagNameMap[T]

The newly created element.

Throws ​

If called outside a browser environment.

Example ​

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

Released under the MIT License.