question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change icon import names to have a prefix e.g. <LucideCamera />

See original GitHub issue

It’s not all the time I run into this issue but I often find myself having to use different icons or renaming components within React projects so that they don’t clash with the imports.

E.g. if I want to use <Login /> Lucide icon but I have a <Login /> functional component.

A suggestion would be to prefix the imports so <Camera /> would become <LcCamera /> or similar.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
ericfenniscommented, Oct 24, 2022

We have a plan to support aliases in all our packages that uses lucide icons as components. I was thinking to add an aliases.js file with all the icons aliases. and export them in the main index.ts. import { Camera } from "lucide-react"; or `import { CameraIcon } from “lucide-react”; will lead to the same icon file. This only will working nicely with ESModules.

If you want to have all the icons you can then still do import * as icons from "lucide-react/icons"; But importing icons this way is not recommended and bad practice if you are bundeling your application for browsers. This way of importing breaks the tree-shaking ability in bundlers. So your bundled app will include all 800+ icons.

2reactions
jakobsencommented, Oct 24, 2022

Another way you could do it is to import as

import * as Lucide from "lucide-react";

and then render components as

<Lucide.Camera />

I think namespacing imports properly should be the responsibility of the app developer, not the library developer, and therefore disagree that this is something that needs a solution from Lucide’s or @ericfennis’ end.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · lucide-icons/lucide - GitHub
Beautiful & consistent icon toolkit made by the community. ... Change icon import names to have a prefix e.g. <LucideCamera /> bug Something...
Read more >
Import Icons | Font Awesome Docs
Here's a primer on Font Awesome icon naming and how to import from icon ... 1) Font Awesome specific style prefix (e.g. fa-solid...
Read more >
How to find Icon names for Font Awesome to import with React?
When you click on an icon you'll see the icon name, e.g. 'arrow-circle-left' but in order to use it like in your above...
Read more >
Docs - IcoMoon
To edit an icon, use the edit/pencil button and then click on an icon cell. ... If you import an SVG font, the...
Read more >
How to use react-icons to install Font Awesome in a React app
Render the icon name as a React element. Code example. import React, { Component } from 'react' ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found