{"id":29613662,"url":"https://github.com/truewinter/domhb","last_synced_at":"2025-07-20T22:08:03.562Z","repository":{"id":303831642,"uuid":"1016945705","full_name":"TrueWinter/domhb","owner":"TrueWinter","description":"A tiny, safe HTML builder for the DOM","archived":false,"fork":false,"pushed_at":"2025-07-09T19:48:28.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-09T21:17:45.986Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TrueWinter.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-09T19:18:16.000Z","updated_at":"2025-07-09T19:48:31.000Z","dependencies_parsed_at":"2025-07-09T21:17:48.151Z","dependency_job_id":"f8adec5f-65a1-414f-8fec-a7a6350fed05","html_url":"https://github.com/TrueWinter/domhb","commit_stats":null,"previous_names":["truewinter/domhb"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TrueWinter/domhb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrueWinter%2Fdomhb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrueWinter%2Fdomhb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrueWinter%2Fdomhb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrueWinter%2Fdomhb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TrueWinter","download_url":"https://codeload.github.com/TrueWinter/domhb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrueWinter%2Fdomhb/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266205774,"owners_count":23892521,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-20T22:08:00.202Z","updated_at":"2025-07-20T22:08:03.548Z","avatar_url":"https://github.com/TrueWinter.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `domhb`: A tiny, safe HTML builder for the DOM\n\nBuild DOM elements without the `document.createElement()` boilerplate using declarative arrays. No frameworks, no state, just plain JavaScript.\n\n## Installation\n\n`domhb` is a client-side ESM-only library available from npm or a CDN.\n\n### From npm\n\n```\nnpm install domhb\n```\n\n```js\nimport hb from 'domhb';\n```\n\n### From CDN\n\n```js\nimport hb from 'https://esm.run/domhb';\n```\n\n## Usage\n\n```ts\nimport hb, { type DOMElement } from 'domhb';\n\nconst elem: DOMElement = [\n  'div',\n  {\n    className: 'btn'\n  },\n  [\n    ['div'],\n    ['button', {\n      style: {\n        backgroundColor: 'cyan'\n      },\n      dataset: {\n        theme: 'light'\n      },\n      disabled: true\n    }],\n    ['p', {}, 'Paragraph']\n  ]\n];\n\n// DOM Element\nconst domElem = hb(elem);\n\n/*\n\u003cdiv class=\"btn\"\u003e\n  \u003cdiv\u003e\u003c/div\u003e\n  \u003cbutton style=\"background-color: cyan;\" data-theme=\"light\" disabled=\"\"\u003e\u003c/button\u003e\n  \u003cp\u003eParagraph\u003c/p\u003e\n\u003c/div\u003e\n*/\n\ndocument.querySelector('#target').appendChild(domElem);\n```\n\n## Why?\n\nI occasionally need to dynamically add elements to my websites that don't justify the overhead of a framework like React - there's no state and no reactivity, so React is overkill. Usually I'd use `document.createElement()` for this, but this approach very quickly becomes hard to manage. It's also hard to understand the structure of the elements from a glance. `domhb` offers a clean, declarative alternative for static or once-off DOM generation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftruewinter%2Fdomhb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftruewinter%2Fdomhb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftruewinter%2Fdomhb/lists"}