Skip to content

Quick start

The icons are dumped on cache warmup. Dump them by hand once, to see the result:

Terminal window
$ php bin/console ux-icons-js:dump -v
* lucide:trash-2
* user
[OK] Dumped 2 icon(s).

It writes var/icons/index.js (and index.d.ts for TypeScript), one named export per local icon: lucide:trash-2 becomes LucideTrash2Icon. Add var/icons/ to your .gitignore if var/ is not ignored already.

import { createIconElement, renderIcon } from '@silarhi/ux-icons-js'
import { LucideTrash2Icon } from '../var/icons/index.js'
button.append(createIconElement(LucideTrash2Icon, { class: 'text-danger', 'aria-label': 'Delete' }))
// or, as an HTML string
button.innerHTML = renderIcon(LucideTrash2Icon, { class: 'text-danger', 'aria-label': 'Delete' })

The output is the one of {{ ux_icon('lucide:trash-2', { class: 'text-danger', 'aria-label': 'Delete' }) }}.

Write the import first, then lock it: ux:icons:lock finds the icons imported in JavaScript, downloads them and dumps them again.

Terminal window
$ php bin/console ux:icons:lock
✓ Imported lucide:mail (License: ISC). Render with: {{ ux_icon('lucide:mail') }}
JavaScript: import { LucideMailIcon }
// Dumped 3 icon(s) for JavaScript.

See remote icons.