https://github.com/clebert/snugjs-html
Create HTML elements and fragments using JSX.
https://github.com/clebert/snugjs-html
Last synced: over 1 year ago
JSON representation
Create HTML elements and fragments using JSX.
- Host: GitHub
- URL: https://github.com/clebert/snugjs-html
- Owner: clebert
- License: mit
- Created: 2022-08-22T07:51:14.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-07-19T21:18:45.000Z (almost 3 years ago)
- Last Synced: 2025-02-24T16:05:08.780Z (over 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 1.32 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# @snugjs/html
> Create HTML elements and fragments using JSX.
## Installation
```
npm install @snugjs/html
```
## Hello World
```jsx
import {createElement} from '@snugjs/html';
document.body.appendChild(
Hello, World!
);
document.body.appendChild(createElement('h1', {}, 'Hello, World!'));
```
## `` Element Factory
```jsx
import {createElement, createElementFactory} from '@snugjs/html';
const Hello = createElementFactory('h1', (element, childNodes) => {
element.replaceChildren('Hello, ', ...childNodes, '!');
});
document.body.appendChild(World);
```
## TypeScript Configuration
```json
{
"jsx": "react",
"jsxFactory": "createElement",
"jsxFragmentFactory": "createFragment"
}
```