fix(lucide): Lucide create element function returning SVG Element (#2816)

* Fix create element function

* Formatting

* Adjust documentation
This commit is contained in:
Eric Fennis
2025-02-24 10:10:28 +01:00
committed by GitHub
parent 1250fc276d
commit 3f2ad5b2a6
7 changed files with 116 additions and 28 deletions
+16 -4
View File
@@ -126,11 +126,23 @@ import { createElement, Menu } from 'lucide';
const menuIcon = createElement(Menu); // Returns HTMLElement (svg)
// set custom attributes with browser native functions
menuIcon.setAttribute('stroke', '#333');
menuIcon.classList.add('my-icon-class');
// Append HTMLElement in the DOM
const myApp = document.getElementById('app');
myApp.appendChild(menuIcon);
```
// Append HTMLElement in webpage
#### Custom Element binding with custom attributes
```js
import { createElement, Menu } from 'lucide';
const menuIcon = createElement(Menu, {
class: ['my-custom-class', 'icon'],
'stroke-width': 1,
stroke: '#333'
}); // Returns HTMLElement (svg)
// Append HTMLElement in the DOM
const myApp = document.getElementById('app');
myApp.appendChild(menuIcon);
```