New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

dotelement

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dotelement

A lightweight React.createElement alternative for vanilla JS

latest
npmnpm
Version
1.0.0
Version published
Maintainers
0
Created
Source

dotElement

dotElement License Downloads

🚀 dotElement is a lightweight utility similar to React.createElement, but for vanilla JavaScript. It allows you to create and manage DOM elements efficiently with a JSX-like approach.

🌟 Features

  • 🏗 JSX-like API for creating DOM elements.
  • 🎨 Styling Support: Apply styles using className or an inline style object (like: {backgroundColor: "red"}).
  • 🎭 Event Listeners: Add event handlers just like in React (onClick, onChange, etc.).
  • 🏎 Lightweight & fast.
  • 🛠 Fully TypeScript-supported.

📦 Installation

Install via npm or pnpm:

npm install dotElement

Or using pnpm:

pnpm add dotElement

🚀 Usage

Basic Example

import { createElement } from "dotElement";

document.body.appendChild(
  createElement("button", {
    className: "btn-primary",
    style: { backgroundColor: "blue", color: "white", padding: "10px" },
    onClick: () => alert("Button Clicked!"),
  }, "Click Me!")
);

Nested Elements Example

const container = createElement("div", { className: "container" },
  createElement("h1", {}, "Hello, dotElement!"),
  createElement("p", {}, "This is a lightweight JSX alternative for vanilla JS."),
  createElement("button", {
    onClick: () => alert("Clicked!"),
    style: { padding: "10px", backgroundColor: "green", color: "white" }
  }, "Click Me")
);

document.body.appendChild(container);

✨ API

createElement(tagName, props?, ...children): HTMLElement

ParameterTypeDescription
tagNamestringThe HTML tag name (e.g., "div", "span").
propsElementProps (optional)Attributes, event listeners, className, and styles.
childrenChildren[]The child elements (text, numbers, elements, or nested arrays).

Props

Styling

  • className → Sets class attribute.
  • style → Supports inline styles as an object or string.

Event Listeners

  • Supports event handlers like React (onClick, onChange, onMouseEnter, etc.).
  • Automatically converts onEventName to the correct event type.

Other Attributes

  • Any valid HTML attribute (e.g., id, title, href, etc.).

🛠 TypeScript Support

dotElement is fully typed! 🎯

const heading: HTMLHeadingElement = createElement("h1", {}, "Welcome!");

📜 License

MIT License © 2025. Feel free to use, modify, and contribute! 🚀

  • NPM: dotElement on npm
  • GitHub: dotElement Repository

💡 Contributions & Issues: Feel free to open an issue or submit a PR on GitHub!

FAQs

Package last updated on 12 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts