--- url: /guide/lucide.md description: >- The core Lucide package for vanilla JavaScript applications. Learn how to add scalable vector icons to any web project without framework dependencies. --- # Lucide for Vanilla JavaScript The core Lucide package for vanilla JavaScript applications. This package allows you to easily add scalable vector icons to any web project without framework dependencies. Perfect for static websites, legacy applications, or when you need lightweight icon integration with maximum browser compatibility. **What you can accomplish:** * Add icons to HTML using simple data attributes * Dynamically create and insert SVG icons with JavaScript * Customize icon appearance with CSS classes and inline styles * Tree-shake unused icons to keep bundle sizes minimal * Use icons in Vanilla JS with HTML Lucide is designed to be lightweight and easy to use, making it an excellent choice for projects that require icons without the overhead of a full framework integration. ## Overview ### Basics {{''}} ### Advanced {{''}} ### Resources {{''}} --- --- url: /guide/lucide/getting-started.md description: >- This guide will help you get started with Lucide in your Vanilla JavaScript project. --- # Getting started This guide will help you get started with Lucide in your Vanilla JavaScript project. Make sure you have a your environment set up. If you don't have one yet, you can create a new project using Vite, Parcel or any other boilerplate of your choice. ## Installation ### Package Managers ::: code-group ```sh [pnpm] pnpm add lucide ``` ```sh [yarn] yarn add lucide ``` ```sh [npm] npm install lucide ``` ```sh [bun] bun add lucide ``` ::: ### CDN ```html ``` We strongly suggest you anchor to a specific version, such as `https://unpkg.com/lucide@x.xxx.x/dist/umd/lucide.min.js`, rather than using `@latest`. This is because the latest version may introduce breaking changes that could potentially break your application. By anchoring to a specific version, you can ensure that your application remains stable and functional, even if there are updates to the library in the future. ## Importing your first icon Lucide is built with ES Modules, so it's completely tree-shakable. The `createIcons` function will search for HTMLElements with the attribute `data-lucide` and replace it with the svg from the given icon name. ### Example ```html ``` ```js import { createIcons, icons } from 'lucide'; // Caution, this will import all the icons and bundle them. createIcons({ icons }); // Recommended way, to include only the icons you need. import { createIcons, Menu, ArrowRight, Globe } from 'lucide'; createIcons({ icons: { Menu, ArrowRight, Globe } }); ``` ## Advanced Usage ### Additional Options In the `createIcons` function you can pass some extra parameters: * you can pass `nameAttr` to adjust the attribute name to replace icons (default is `data-lucide`). * you can pass `attrs` to pass additional custom attributes, for instance CSS classes or stroke options. * you can pass `root` to provide a custom DOM element the icons should be replaced in (useful when manipulating small sections of a large DOM or elements in the shadow DOM) * you can pass `inTemplates: true` to also replace icons inside `