### Install Lucide for Solid Source: https://lucide.dev/guide/installation Install the Lucide library for Solid applications. ```sh pnpm add lucide-solid@next ``` ```sh yarn add lucide-solid@next ``` ```sh npm install lucide-solid@next ``` ```sh bun add lucide-solid@next ``` -------------------------------- ### Install @lucide/icons Source: https://lucide.dev/guide/packages/icons Install the package using your preferred package manager. ```sh pnpm add @lucide/icons ``` ```sh yarn add @lucide/icons ``` ```sh npm install @lucide/icons ``` ```sh bun add @lucide/icons ``` -------------------------------- ### Install Lucide for Astro Source: https://lucide.dev/guide/installation Install the Lucide library for Astro applications. ```sh pnpm add @lucide/astro@next ``` ```sh yarn add @lucide/astro@next ``` ```sh npm install @lucide/astro@next ``` ```sh bun add @lucide/astro@next ``` -------------------------------- ### Install Lucide for Preact Source: https://lucide.dev/guide/installation Install the Lucide library for Preact applications. ```sh pnpm add lucide-preact@next ``` ```sh yarn add lucide-preact@next ``` ```sh npm install lucide-preact@next ``` ```sh bun add lucide-preact@next ``` -------------------------------- ### Installation Source: https://lucide.dev/guide/packages/icons Install the @lucide/icons package using your preferred package manager. ```APIDOC ## Installation ::: code-group ```sh [pnpm] pnpm add @lucide/icons ``` ```sh [yarn] yarn add @lucide/icons ``` ```sh [npm] npm install @lucide/icons ``` ```sh [bun] bun add @lucide/icons ``` ::: ``` -------------------------------- ### Install lucide-static Source: https://lucide.dev/guide/packages/lucide-static Install the lucide-static package using your preferred package manager. ```sh pnpm add lucide-static ``` ```sh yarn add lucide-static ``` ```sh npm install lucide-static ``` ```sh bun add lucide-static ``` -------------------------------- ### Using Lucide Icons in JavaScript Projects Source: https://lucide.dev/guide/static/font Example setup for using the icon font within a JavaScript-based environment. ```html ``` ```js import "./styles.css"; import "lucide-static/font/lucide.css"; ``` -------------------------------- ### Install Lucide for Web Source: https://lucide.dev/guide/installation Install the core Lucide library for general web applications. ```sh pnpm add lucide@next ``` ```sh yarn add lucide@next ``` ```sh npm install lucide@next ``` ```sh bun add lucide@next ``` -------------------------------- ### Install Lucide for React Source: https://lucide.dev/guide/installation Install the Lucide library for React applications. ```sh pnpm add lucide-react@next ``` ```sh yarn add lucide-react@next ``` ```sh npm install lucide-react@next ``` ```sh bun add lucide-react@next ``` -------------------------------- ### Node.js HTTP Server with Lucide Icon Source: https://lucide.dev/guide/static/js-modules/node An example of creating a basic Node.js HTTP server that renders an HTML page including a Lucide icon. Ensure 'lucide-static' is installed as a dependency. ```js import http from 'http'; import { MessageSquare } from 'lucide-static'; const server = http.createServer((req, res) => { res.statusCode = 200; res.setHeader('Content-Type', 'text/html'); res.end(`

Lucide Icons

This is a Lucide icon ${MessageSquare}

`); }); const hostname = '127.0.0.1'; const port = 3000; server.listen(port, hostname, () => { console.log(`Server running at http://${hostname}:${port}/`); }); ``` -------------------------------- ### Install Lucide for Vue Source: https://lucide.dev/guide/installation Install the Lucide library for Vue applications. ```sh pnpm add @lucide/vue ``` ```sh yarn add @lucide/vue ``` ```sh npm install @lucide/vue ``` ```sh bun add @lucide/vue ``` -------------------------------- ### Installation Source: https://lucide.dev/guide/vue/getting-started Commands to install the Lucide Vue package using various package managers. ```APIDOC ## Installation ### Description Install the @lucide/vue package to use Lucide icons in your Vue project. ### Commands - **pnpm**: `pnpm add @lucide/vue` - **yarn**: `yarn add @lucide/vue` - **npm**: `npm install @lucide/vue` - **bun**: `bun add @lucide/vue` ``` -------------------------------- ### Example Using CDN with Customization Source: https://lucide.dev/guide/lucide/getting-started Demonstrates using Lucide with a CDN and the `createIcons` function, including custom classes and attributes. ```html ``` -------------------------------- ### Install Lucide React Source: https://lucide.dev/guide/react/getting-started Install the lucide-react package using your preferred package manager. ```sh pnpm add lucide-react ``` ```sh yarn add lucide-react ``` ```sh npm install lucide-react ``` ```sh bun add lucide-react ``` -------------------------------- ### Install Lucide React Native Source: https://lucide.dev/guide/packages/lucide-react-native Install the package using your preferred package manager. Ensure react-native-svg is installed and compatible. ```sh pnpm add lucide-react-native ``` ```sh yarn add lucide-react-native ``` ```sh npm install lucide-react-native ``` ```sh bun add lucide-react-native ``` -------------------------------- ### Install lucide-preact Source: https://lucide.dev/guide/packages/lucide-preact Add the lucide-preact package to your project using your preferred package manager. ```sh pnpm add lucide-preact ``` ```sh yarn add lucide-preact ``` ```sh npm install lucide-preact ``` ```sh bun add lucide-preact ``` -------------------------------- ### Install Lucide with Package Managers Source: https://lucide.dev/guide/lucide/getting-started Install Lucide using your preferred package manager. ```sh pnpm add lucide ``` ```sh yarn add lucide ``` ```sh npm install lucide ``` ```sh bun add lucide ``` -------------------------------- ### Install Lucide Vue package Source: https://lucide.dev/guide/vue/getting-started Install the package using your preferred package manager. ```sh pnpm add @lucide/vue ``` ```sh yarn add @lucide/vue ``` ```sh npm install @lucide/vue ``` ```sh bun add @lucide/vue ``` -------------------------------- ### Install @lucide/angular with bun Source: https://lucide.dev/guide/packages/angular Use this command to add the @lucide/angular package to your project using bun. ```sh bun add @lucide/angular ``` -------------------------------- ### Use Generic Icon Component Source: https://lucide.dev/guide/packages/lucide-astro Implementation example for the generic icon component. ```astro --- import LucideIcon from './LucideIcon.astro'; --- ``` -------------------------------- ### Install Lucide for Static Usage Source: https://lucide.dev/guide/installation Install the Lucide library for static assets like SVG files, sprites, and icon fonts. ```sh pnpm add lucide-static@next ``` ```sh yarn add lucide-static@next ``` ```sh npm install lucide-static@next ``` ```sh bun add lucide-static@next ``` -------------------------------- ### Install @lucide/astro Source: https://lucide.dev/guide/astro/getting-started Install the Lucide Astro package using your preferred package manager. ```sh pnpm add @lucide/astro ``` ```sh yarn add @lucide/astro ``` ```sh npm install @lucide/astro ``` ```sh bun add @lucide/astro ``` -------------------------------- ### Install Lucide Svelte Package Source: https://lucide.dev/guide/packages/lucide-svelte Choose the appropriate command for your package manager to install the @lucide/svelte package. ```sh pnpm add @lucide/svelte ``` ```sh yarn add @lucide/svelte ``` ```sh npm install @lucide/svelte ``` ```sh bun add @lucide/svelte ``` -------------------------------- ### Create a Generic Icon Component (Not Recommended) Source: https://lucide.dev/guide/packages/lucide-preact This example demonstrates creating a single component to load icons dynamically by name. Caution: Importing all icons can significantly increase build size and negatively impact performance. ```jsx import { icons } from 'lucide-preact'; const Icon = ({ name, color, size }) => { const LucideIcon = icons[name]; return ; }; export default Icon; ``` -------------------------------- ### Install Lucide for Svelte Source: https://lucide.dev/guide/installation Install the Lucide library for Svelte 5 applications. Use lucide-svelte for Svelte 4. ```sh pnpm add @lucide/svelte@next ``` ```sh yarn add @lucide/svelte@next ``` ```sh npm install @lucide/svelte@next ``` ```sh bun add @lucide/svelte@next ``` -------------------------------- ### Install @lucide/angular with npm Source: https://lucide.dev/guide/packages/angular Use this command to add the @lucide/angular package to your project using npm. ```sh npm install @lucide/angular ``` -------------------------------- ### Using the Generic Icon Component Source: https://lucide.dev/guide/packages/lucide-svelte Example of how to use a generic icon component to render specific Lucide icons by name. ```svelte ``` -------------------------------- ### Install Lucide Solid Source: https://lucide.dev/guide/packages/lucide-solid Commands to add the lucide-solid package to your project using various package managers. ```sh pnpm add lucide-solid ``` ```sh yarn add lucide-solid ``` ```sh npm install lucide-solid ``` ```sh bun add lucide-solid ``` -------------------------------- ### Install @lucide/angular with yarn Source: https://lucide.dev/guide/packages/angular Use this command to add the @lucide/angular package to your project using yarn. ```sh yarn add @lucide/angular ``` -------------------------------- ### Install lucide-react and remove react-feather Source: https://lucide.dev/guide/react/migration-from-feather Use these commands to swap the icon library dependencies in your project. ```sh npm install lucide-react npm uninstall react-feather ``` -------------------------------- ### Install @lucide/angular package Source: https://lucide.dev/guide/angular/getting-started Use your preferred package manager to add the Lucide Angular library to your project. ```sh pnpm add @lucide/angular ``` ```sh yarn add @lucide/angular ``` ```sh npm install @lucide/angular ``` ```sh bun add @lucide/angular ``` -------------------------------- ### Install @lucide/angular with pnpm Source: https://lucide.dev/guide/packages/angular Use this command to add the @lucide/angular package to your project using pnpm. ```sh pnpm add @lucide/angular ``` -------------------------------- ### Using Filled Stars in Preact Source: https://lucide.dev/guide/preact/advanced/filled-icons Demonstrates how to apply fill colors to Lucide star icons in a Preact application. Ensure 'lucide-preact' is installed. The 'strokeWidth' is set to 0 to rely solely on the fill. ```jsx import { Star, StarHalf } from "lucide-preact"; import { h } from "preact"; import "./icon.css"; function App() { return (
{ Array.from({ length: 5 }, () => ( ))}
); } export default App; ``` ```css .star-rating { position: relative; } .stars { display: flex; gap: 4px; } .rating { position: absolute; top: 0; } ``` -------------------------------- ### JSDoc Example for Menu Items in Svelte 5 Source: https://lucide.dev/guide/packages/lucide-svelte Defines menu items with icons using JSDoc for type safety in Svelte 5. Ensure the 'icon' property correctly references the imported Lucide icon component. ```svelte {#each menuItems as item} {@const Icon = item.icon} {item.name} {/each} ``` -------------------------------- ### Initialize Lucide Icons with Custom Icons Source: https://lucide.dev/guide/lucide/advanced/with-lucide-lab Import necessary icons from `lucide/dist/cjs/lucide` and custom icons from `@lucide/lab`. Use `createIcons` to register and render these icons in your application. ```javascript import "./styles.css"; import { createIcons, Smile } from 'lucide/dist/cjs/lucide'; import { avocado as Avocado } from '@lucide/lab'; createIcons({ icons: { Avocado, } }); ``` -------------------------------- ### Direct Icon Imports Source: https://lucide.dev/guide/packages/lucide-astro Importing icons directly from the icons directory for faster builds. ```astro --- import CircleAlert from '@lucide/astro/icons/circle-alert'; --- ``` -------------------------------- ### Direct Icon Import for Optimization Source: https://lucide.dev/guide/packages/lucide-svelte For faster builds, import icons directly from the '@lucide/svelte/icons' directory. This improves tree-shaking efficiency. ```svelte ``` -------------------------------- ### Import and Render First Icon Source: https://lucide.dev/guide/lucide/getting-started Import icons and use the `createIcons` function to replace HTML elements with SVG icons. Importing only necessary icons is recommended for tree-shaking. ```html ``` ```js import { createIcons, icons } from 'lucide'; // Caution, this will import all the icons and bundle them. createIcons({ icons }); ``` ```js import { createIcons, Menu, ArrowRight, Globe } from 'lucide'; createIcons({ icons: { Menu, ArrowRight, Globe } }); ``` -------------------------------- ### Import and use a Lucide icon in React Native Source: https://lucide.dev/guide/react-native/getting-started Import icons as React components and use them directly in your JSX. Ensure you have react-native-svg installed. ```jsx import { Camera } from 'lucide-react-native'; // Usage const App = () => { return ; }; export default App; ``` -------------------------------- ### Provide Icons via Dependency Injection Source: https://lucide.dev/guide/packages/angular Configure icons globally or at a specific level using `provideLucideIcons`. This allows the `LucideIcon` component to render icons based on string names. ```ts import { ApplicationConfig } from '@angular/core'; import { provideLucideIcons, LucideCircleCheck, LucideCircleX } from '@lucide/angular'; export const appConfig: ApplicationConfig = { providers: [ // ... provideLucideIcons( LucideCircleCheck, LucideCircleX, ), ] }; ``` ```html ``` ```ts import { Component } from '@angular/core'; import { LucideIcon } from '@lucide/angular'; @Component({ selector: 'app-foobar', templateUrl: './template-url', imports: [LucideIcon], }) export class Foobar { } ``` -------------------------------- ### Apply Custom Props to Icons Source: https://lucide.dev/guide/packages/lucide-react-native Customize icon appearance by passing SVG attributes as props. This example shows how to apply a fill color. ```jsx // Usage const App = () => { return ; }; ``` -------------------------------- ### Set Icon Color with `color` Prop in Vue Source: https://lucide.dev/guide/vue/basics/color Use the `color` prop to directly set the icon's color. Ensure the `@lucide/vue` dependency is installed. ```vue ``` -------------------------------- ### Set Icon Color with `color` Prop in Solid Source: https://lucide.dev/guide/solid/basics/color Use the `color` prop to directly set the icon's color. Ensure the `lucide-solid` dependency is installed. ```tsx import Smile from 'lucide-solid/icons/smile'; function App() { return (
); } export default App; ``` -------------------------------- ### Set Icon Color with `color` Prop in Preact Source: https://lucide.dev/guide/preact/basics/color Use the `color` prop to directly set the icon's color. Ensure the `lucide-preact` dependency is installed. ```javascript import { h } from "preact"; import { Smile } from "lucide-preact"; function App() { return (
); } export default App; ``` -------------------------------- ### Importing Lucide icons with different naming styles Source: https://lucide.dev/guide/preact/advanced/aliased-names Demonstrates that multiple import names can refer to the same icon component. ```tsx // These are all the same icon import { House, HouseIcon, LucideHouse, } from "lucide-preact"; ``` -------------------------------- ### Adjust Icon Size with CSS Source: https://lucide.dev/guide/astro/basics/sizing Apply CSS `width` and `height` properties to control icon size. This example uses a CSS class to style the icon. ```css .my-beer-icon { width: 64px; height: 64px; } ``` ```astro ---import Beer from '@lucide/astro/icons/beer'; import './icon.css' --- ``` -------------------------------- ### Apply Global Styles to Icons with LucideProvider Source: https://lucide.dev/guide/react-native/advanced/global-styling Use the LucideProvider component to set default color, size, and stroke width for all child icons. Ensure 'lucide-react-native' is installed. ```tsx import { LucideProvider, Home } from 'lucide-react-native'; const App = () => ( ); ``` -------------------------------- ### Migrate global configuration Source: https://lucide.dev/guide/angular/migration Replaces legacy LucideIconConfig injection with provideLucideConfig. ```typescript import { inject } from '@angular/core'; import { LucideIconConfig } from 'lucide-angular'; inject(LucideIconConfig).size = 12; ``` ```typescript import { provideLucideConfig } from '@lucide/angular'; providers: [ provideLucideConfig({ size: 12 }), ] ``` -------------------------------- ### Displaying Icons as HTML Images Source: https://lucide.dev/guide/static/link-as-image Use the img tag to reference Lucide SVG files. Ensure the path matches your project's build tool configuration or use a versioned CDN URL. ```html Smile Icon ``` ```html Smile Icon ``` ```html Smile Icon ``` -------------------------------- ### Provide Lucide Lab Icon by Name in Angular Source: https://lucide.dev/guide/angular/advanced/with-lucide-lab Register custom icons from Lucide Lab using `provideLucideIcons` and `lucideLegacyIcon` for use by name in templates. Requires installation of `@lucide/lab`. ```typescript import { Component, ViewEncapsulation } from "@angular/core"; import { LucideDynamicIcon } from '@lucide/angular'; @Component({ selector: 'app', template: ` `, imports: [LucideDynamicIcon], styleUrls: ['./app.component.css'], encapsulation: ViewEncapsulation.None, }) export class App { } ``` ```typescript import { ApplicationConfig } from '@angular/core'; import { lucideLegacyIcon, provideLucideIcons } from '@lucide/angular'; import { batBall } from '@lucide/lab'; export const appConfig: ApplicationConfig = { providers: [ provideLucideIcons( lucideLegacyIcon('bat-ball', batBall) ) ] }; ``` -------------------------------- ### Use Lucide Lab Icon Directly as LucideIconData in Angular Source: https://lucide.dev/guide/angular/advanced/with-lucide-lab Pass custom icons from Lucide Lab directly to the LucideIcon component using `lucideLegacyIcon`. Ensure `@lucide/lab` is installed. ```typescript import { Component, ViewEncapsulation, signal } from "@angular/core"; import { LucideDynamicIcon, lucideLegacyIcon } from '@lucide/angular'; import { coconut } from '@lucide/lab'; @Component({ selector: 'app', template: ` `, imports: [LucideDynamicIcon], styleUrls: ['./app.component.css'], encapsulation: ViewEncapsulation.None, }) export class App { readonly icon = signal(lucideLegacyIcon('coconut', coconut)); } ``` -------------------------------- ### Adjust icon stroke width with `strokeWidth` prop Source: https://lucide.dev/guide/preact/basics/stroke-width Use the `strokeWidth` prop to directly control the thickness of the icon's strokes. This example sets the stroke width to 1px. ```jsx import { h } from "preact"; import { FolderLock } from "lucide-preact"; function App() { return (
); } export default App; ``` -------------------------------- ### Import icons Source: https://lucide.dev/guide/packages/icons Import icons individually to ensure tree-shaking works correctly. ```typescript import { House } from '@lucide/icons'; // House is icon data (not a rendered component). ``` -------------------------------- ### Adjust icon color with the color prop in React Native Source: https://lucide.dev/guide/react-native/basics/color Pass a color string to the color prop to override the default icon color. This example uses the Smile icon from lucide-react-native. ```javascript import React, {useState, useEffect} from 'react'; import { View } from 'react-native'; import { Smile } from "lucide-react-native"; const style = { height: '100%', alignItems: 'center', display: 'flex', justifyContent: 'center' } const App = () => { return ( ); }; export default App; ``` -------------------------------- ### Importing icons with different naming styles Source: https://lucide.dev/guide/react-native/advanced/aliased-names Demonstrates that multiple import names can refer to the same icon. ```tsx // These are all the same icon import { House, HouseIcon, LucideHouse, } from "lucide-react-native"; ``` -------------------------------- ### Generic Icon Component Implementation Source: https://lucide.dev/guide/packages/lucide-react-native Create a single icon component to dynamically load icons by name. Caution: Importing all icons can significantly increase build size and impact performance. ```tsx import * as icons from 'lucide-react-native/icons'; interface IconProps { name: keyof typeof icons; color?: string; size?: number; } const Icon = ({ name, color, size }: IconProps) => { const LucideIcon = icons[name]; return ; }; export default Icon; ``` -------------------------------- ### Inherit Parent Text Color for Svelte Icons Source: https://lucide.dev/guide/svelte/basics/color Icons utilize `currentColor`, so they inherit the computed text color from their parent elements. This example shows an icon within a button styled with a white color. ```svelte ``` -------------------------------- ### Importing icons with different naming styles Source: https://lucide.dev/guide/react/advanced/aliased-names Demonstrates that multiple import names can refer to the same icon component. ```tsx // These are all the same icon import { House, HouseIcon, LucideHouse, } from "lucide-react"; ``` -------------------------------- ### Inherit Color from Parent Element in Astro Source: https://lucide.dev/guide/astro/basics/color Lucide icons use `currentColor` by default, so they inherit the text color from their parent elements. This example shows an icon inside a button styled with `color:#fff`. ```astro --- import ThumbsUp from '@lucide/astro/icons/thumbs-up'; --- ``` -------------------------------- ### HTML Structure for Lucide Icons Source: https://lucide.dev/guide/static/js-modules/web Basic HTML boilerplate required to host the application and load the script. ```html
``` -------------------------------- ### Configure global defaults with provideLucideConfig Source: https://lucide.dev/guide/angular/advanced/global-styling Register the provider in your application configuration to set default properties for all icons while allowing individual overrides. ```ts import { ApplicationConfig } from '@angular/core'; import { provideLucideConfig } from '@lucide/angular'; export const appConfig: ApplicationConfig = { providers: [ provideLucideConfig({ strokeWidth: 1.5 }), ] }; ``` -------------------------------- ### Using Filled Icons in React Native Source: https://lucide.dev/guide/react-native/advanced/filled-icons Demonstrates how to apply fill colors to Lucide icons in React Native. Note that fills are not officially supported but can work on specific icons. Ensure `react-native-svg` and `lucide-react-native` are installed. ```javascript import React, {useState, useEffect} from 'react'; import { View, StyleSheet } from 'react-native'; import { Star, StarHalf } from "lucide-react-native"; const App = () => { return ( { Array.from({ length: 5 }, () => ( ))} ); }; const styles = StyleSheet.create({ container: { height: '100%', alignItems: 'center', display: 'flex', justifyContent: 'center' }, starRating: { position: 'relative', }, stars: { display: 'flex', flexDirection: 'row', gap: 4, }, rating: { position: 'absolute', top: 0, } }); export default App; ``` -------------------------------- ### Create Custom Lucide Icon Component in Angular Source: https://lucide.dev/guide/angular/advanced/with-lucide-lab Define a custom, standalone icon component in Angular using `LucideIconBase` and `lucideIconTemplate`. Ensure the selector follows the `svg[lucide{IconName}]` pattern and `@lucide/lab` is installed. ```typescript import { LucideIconBase, lucideIconTemplate, lucideLegacyIcon } from '@lucide/angular'; import { Component, signal } from '@angular/core'; import { bottleChampagne } from '@lucide/lab'; @Component({ selector: 'svg[lucideBottleChampagne]', template: lucideIconTemplate, standalone: true, }) export class LucideBottleChampagne extends LucideIconBase { static readonly icon = lucideLegacyIcon('bottle-champagne', bottleChampagne); protected override readonly icon = signal(LucideBottleChampagne.icon); } ``` ```typescript import { Component, ViewEncapsulation, signal } from "@angular/core"; import { LucideDynamicIcon, lucideLegacyIcon } from '@lucide/angular'; import { LucideBottleChampagne } from "../icons/bottle-champagne"; @Component({ selector: 'app', template: ``, imports: [LucideBottleChampagne], styleUrls: ['./app.component.css'], encapsulation: ViewEncapsulation.None, }) export class App { } ``` -------------------------------- ### Advanced Lucide Configuration Source: https://lucide.dev/guide/lucide/getting-started Customize icon replacement behavior using options like `nameAttr`, `attrs`, `root`, and `inTemplates` in the `createIcons` function. ```js import { createIcons } from 'lucide'; createIcons({ attrs: { class: ['my-custom-class', 'icon'], 'stroke-width': 1, stroke: '#333' }, nameAttr: 'data-lucide', // attribute for the icon name. root: element, // DOM element to replace icons in. inTemplates: true // Also replace icons inside