lucide-icons / lucide

Beautiful & consistent icon toolkit made by the community. Open-source project and a fork of Feather Icons.
https://lucide.dev
ISC License
8.94k stars 380 forks source link

Find icon by name #2091

Closed bernaferrari closed 1 month ago

bernaferrari commented 1 month ago

Package

Description

I wish I could do:

if (iconStr in icons) {
  return icons[iconStr];
}

or

icons.findName(d)

Maybe you could expose an array in lucide-static, a json file, or something else that made easy for me.

From the own docs, it says:

JavaScript library containing strings of SVGs

Yet I don't know how to get "all strings of svgs" all it once in a single place.

Checklist

ericfennis commented 1 month ago

Does this not work for you?

import * as icons from "lucide-static";

const iconsArray = Object.values(icons)

What is the exact usecase?

bernaferrari commented 1 month ago

I'm going to sound extremely dumb, but that worked... I tried before (multiple times) but somehow I was getting wrong types and stuff. Thanks a lot.

jguddas commented 1 month ago

Does this not work for you?

import * as icons from "lucide-static";

const iconsArray = Object.values(icons)

What is the exact usecase?

Bundle size is probably going to be horrible tho.

bernaferrari commented 1 month ago

It is on the server, so it is fine.