-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Supertype for icons? #542
Comments
Since all icons are just taking type Icon = React.ComponentType<React.ComponentProps<'svg'>>; |
Good point, I ended up figuring that out and forgot to close earlier. Thanks! |
It seems in a recent update that definition no longer applies. Anyone know what it should be now? |
This works for me: export type HeroIcon = React.ComponentType<
React.PropsWithoutRef<React.ComponentProps<"svg">> & {
title?: string | undefined;
titleId?: string | undefined;
}
>; I think you can also just do something like get the typeof an example icon: import { PencilIcon } from "@heroicons/react/24/outline";
export type HeroIcon = typeof PencilIcon; Both have upsides and downsides. |
As of #64, there's now Typescript types for the icons. I was hoping though that there could be some sort of "supertype" for all the icons, so that I could define a React component that would require an icon instead of just a generic ReactNode. My usecase is I'm trying to make a generic version of this component from Tailwind UI, and it would be nice if I could make it so a generic icon could be provided.
The text was updated successfully, but these errors were encountered: