icons next js npm packages react components react js

Using Lucide React Icons in Nextjs | React js

Lucide offers a sleek and versatile icon library that seamlessly integrates with your Next.js or React applications. Let’s explore how to leverage Lucide for beautiful, customizable icons:

Lucide is an open-source icon library that provides 1000+ vector (SVG) files for displaying icons and symbols in digital and non-digital projects.

Lucide can be used in any app, it has an npm package, especially for React i.e, lucide-react that can be used in React applications as well as Nextjs apps.

Let’s see how we can use Lucide Icons in our Nextjs app ( you can follow this tutorial for React also ).

Step 1: Installation

Let’s start by installing lucide-react it in our project.

npm install lucide-react
yarn add lucide-react
pnpm install lucide-react

Step 2: Using icons

Each icon can be imported as a React component, which renders an inline SVG element. This way, only the icons that are imported into your project are included in the final bundle. Any other icons that you don’t use will be removed automatically.

Below is the basic example of using an icon component from Lucide icons.

import { Home} from 'lucide-react';

// Usage
const App = () => {
  return <Home color="red" size={48} />;
};

export default App;

The following categories of icons are available


Accessibility
Accounts & access
Animals
Arrows
Brands
Buildings
Charts
Communication
Connectivity
Currency
Cursors
Design
Coding & development
Devices
Emoji
File icons
Food & beverage
Furniture
Gaming
Home
Layout
Mail
Maps
Maths
Medical
Money
Multimedia
Nature
Navigation
Notifications
People
Photography
Science
Seasons
Security
Shapes
Shopping
Social
Sports
Sustainability
Text formatting
Time & calendar
Tools
Transportation
Travel
Weather

Step 3: Customization

image not found

We can change size, color, and stroke width by passing props to Icon components

Like here, I am passing the green color to Home icon we used earlier.

import { Home} from 'lucide-react';

// Usage
const App = () => {
  return <Home color="green" size={48} />;3
};

export default App;

Following are all the available props for lucid icons.

nametypedefault
sizenumber24
colorstringcurrentColor
strokeWidthnumber2
absoluteStrokeWidthbooleanfalse

Conclusion

Hope this quick tutorial helped you get started with lucide icons in your React or Nextjs application, If you want to explore the depth of it visit the official documentation.

Related Posts

How To Install and Use Flowbite in Next js

Flowbite is an open-source library of UI components based on the utility-first Tailwind CSS framework featuring dark mode support, a Figma design system, templates, and more. It provides…

Using Notistack in Nextjs | React js

Showing toast messages in react apps is a common feature to add, as it’s one of the quickest ways to give feedback to users. There are many toast…

Using React Feather Icons in Next js

Feather Icons is a collection of sleek and beautiful icons that you can use in your projects in different ways and integrate seamlessly with React-based applications. To use…

find unused npm packages

Find and Remove Unused NPM Packages from Your Project

While building apps in an NPM environment it’s easy to accumulate lots of NPM packages in our app that we don’t even need, these package slows down our…

Using Bootstrap Icons in Next js | React

Bootstrap Icons is a Free, high-quality, open-source icon library with over 2,000 icons. You can use them as you like SVGs, SVG sprite, or web fonts. We can…

Best toast notification libraries for Next js

One of the most liked aspects of the React Ecosystem is that you can find components and libraries for almost everything you want to implement in your React…

Leave a Reply

Your email address will not be published. Required fields are marked *