icon
fulldev-ui/iconFreeComponent
fulldev/ui publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by fulldev/ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://ui.full.dev/r/icon.jsonSource
1---2import type { HTMLAttributes } from "astro/types"34type Props = Omit<HTMLAttributes<"svg">, "name" | "href"> & {5 href?: HTMLAttributes<"a">["href"]6 name?: string | number | null7}89const { name, href, ...props } = Astro.props1011const hrefMap = {12 "x.com": "x",13 twitter: "twitter",14 facebook: "facebook",15 instagram: "instagram",16 pinterest: "pinterest",17 youtube: "youtube",18 tiktok: "tiktok",19 snapchat: "snapchat",20 reddit: "reddit",21 tumblr: "tumblr",22 "wa.me": "whatsapp",23 telegram: "telegram",24 discord: "discord",25 vimeo: "vimeo",26 flickr: "flickr",27 yelp: "yelp",28 spotify: "spotify",29 behance: "behance",30 dribbble: "dribbble",31 soundcloud: "soundcloud",32 github: "github",33 twitch: "twitch",34 "tel:": "phone",35 "mailto:": "mail",36 "maps.app.goo.gl": "map-pin",37 linkedin: "linkedin",38} as const3940const icons = import.meta.glob(41 [42 "/node_modules/lucide-static/icons/*.svg",43 "/node_modules/simple-icons/icons/*.svg",44 ],45 { eager: true }46) as Record<string, { default: any }>4748const foundPath = () => {49 let foundPath: string | undefined = undefined5051 // For x.com, use the Simple Icons X instead of Lucide's X icon.52 if (name === "x.com") {53 foundPath = "/node_modules/simple-icons/icons/x.svg"54 } else if (name) {55 foundPath = Object.keys(icons).find((key) => key.includes(`/${name}.svg`))56 } else if (href) {57 const hrefKey = Object.keys(hrefMap).find((key) =>58 href.toString().includes(key)59 )60 const hrefValue = hrefMap[hrefKey as keyof typeof hrefMap]61 foundPath = Object.keys(icons)62 .reverse()63 .find((key) => key.includes(`/${hrefValue}.svg`))64 }6566 return foundPath67}6869const iconPath = foundPath()70const module = iconPath ? icons[iconPath] : undefined71const Comp = module?.default72---7374{75 Comp && foundPath()?.includes("simple-icons") && (76 <Comp77 height={24}78 width={24}79 fill="currentColor"80 class="size-[1em] text-base"81 {...props}82 />83 )84}8586{87 Comp && foundPath()?.includes("lucide-static") && (88 <Comp89 height={24}90 width={24}91 fill="none"92 class="size-[1em] text-base"93 {...props}94 />95 )96}
What it pulls in
npm packages
Files it writes
More from fulldev/ui
All 144 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | fulldev/ui | Components | Free | 1 dep · 5 files | |
| alertalert | fulldev/ui | Components | Free | no deps · 5 files | |
| alert-dialogalert-dialog | fulldev/ui | Components | Free | 1 dep · 13 files | |
| avataravatar | fulldev/ui | Components | Free | no deps · 7 files | |
| badgebadge | fulldev/ui | Components | Free | no deps · 3 files | |
| bannerbanner | fulldev/ui | Components | Free | no deps · 3 files | |
| breadcrumbbreadcrumb | fulldev/ui | Components | Free | no deps · 8 files | |
| buttonbutton | fulldev/ui | Components | Free | no deps · 3 files |
