Hi. what the type of a lucide-react icon is? #1869
-
|
Does anyone know what is the type of a lucide-react icon? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 4 replies
-
|
I'm not sure if this is what you meant, but it generates an inline SVG element. You can find more info here - https://lucide.dev/guide/packages/lucide-react |
Beta Was this translation helpful? Give feedback.
-
|
I think @skdishansachin means in typescript, if we have an object with "icon" key, what type of return we have to add? I also need this Edit: Ok I found the solution: import { LucideIcon } from "lucide-react";
export type TestInterface = {
title: string;
icon: LucideIcon;
};And when you use your import { ArrowBigUp } from "lucide-react";
const test: TestInterface = {
title: "Test title",
icon: ArrowBigUp // be careful, don't use as a component like <ArrowBigUp />
} |
Beta Was this translation helpful? Give feedback.
-
|
Well you can use Exmaple: |
Beta Was this translation helpful? Give feedback.
-
|
Can you share how it works after importing? Do we just go test.icon and it becomes that or do we have to wrap it in <> brackets? |
Beta Was this translation helpful? Give feedback.
-
|
If anyone use DynamicIcon component. You can also declear type like this: keyof typeof dynamicIconImports |
Beta Was this translation helpful? Give feedback.

I think @skdishansachin means in typescript, if we have an object with "icon" key, what type of return we have to add? I also need this
Edit:
Ok I found the solution:
And when you use your
TestInterface, you have to use like this: