IconSearch logoIconsearch
TYPESCRIPT ARCHITECTURE & TYPE SAFETY
Last updated: September 2026

TypeScript Icons: Strict Typing & Polymorphic Wrappers (2026)

Eliminate runtime SVG rendering bugs with strict TypeScript interfaces. Discover how typed icon properties, generic polymorphic components, and IDE autocompletion improve developer productivity.

100% Type-Safe: 11 verified libraries ship native .d.ts declarations.

How do you build a strictly typed polymorphic SVG icon component in TypeScript?

A strictly typed polymorphic SVG icon wrapper in TypeScript extends React.ComponentPropsWithoutRef<'svg'> while accepting a generic icon component type like LucideIcon. This centralizes default sizing, accessibility attributes (aria-hidden), and theme utility classes while maintaining full compile-time autocomplete and prop validation. Wrapping primitives ensures that design system tokens remain consistent across your engineering organization while preserving native SVG attribute passthrough.

// components/ui/icon.tsx
import React from 'react'
import { LucideIcon, LucideProps } from 'lucide-react'

export interface IconProps extends Omit<LucideProps, 'ref'> {
  icon: LucideIcon
  label?: string // Optional accessible label
  className?: string
}

export function AppIcon({ icon: IconComponent, label, className = '', size = 20, ...rest }: IconProps) {
  return (
    <IconComponent
      size={size}
      className={className}
      aria-hidden={!label}
      aria-label={label}
      role={label ? 'img' : 'presentation'}
      {...rest}
    />
  )
}

// Usage in your React / Next.js app:
// <AppIcon icon={Home} size={24} className="text-blue-500" label="Go to homepage" />

Which icon libraries provide native TypeScript definition files?

Modern icon libraries including Lucide React, Heroicons, Tabler Icons, Radix Icons, and Phosphor Icons ship native `.d.ts` declaration files. These declarations provide instant IntelliSense in VS Code, type-safe prop interfaces, and strict prop checking under TypeScript 5+. The comparison table below highlights TypeScript support across major libraries:

TypeScript Type Definition Support Matrix (2026)
LibraryTotal IconsLicenseTypeScript DeclarationsModule ResolutionPrimary NPM Package
Lucide Icons1,960ISCNative .d.ts / .d.mtsBundler & Node16lucide-react
Heroicons324MITNative .d.ts / .d.mtsBundler & Node16@heroicons/react
Tabler Icons6,147MITNative .d.ts / .d.mtsBundler & Node16@tabler/icons-react
PatternFly Icons2,884MITNative .d.ts / .d.mtsBundler & Node16@patternfly/react-icons
Untitled UI Icons1,179MITNative .d.ts / .d.mtsBundler & Node16@untitledui/icons
Phosphor Icons1,533MITNative .d.ts / .d.mtsBundler & Node16@phosphor-icons/react
Radix Icons318MITNative .d.ts / .d.mtsBundler & Node16@radix-ui/react-icons
Iconoir1,384MITNative .d.ts / .d.mtsBundler & Node16iconoir-react

Core Advantages of Native TypeScript Support

✓ IntelliSense Autocomplete

VS Code and JetBrains IDEs instantly suggest symbol names as you type, reducing typos and API lookups.

✓ Prop Type Validation

Catch invalid size strings, missing colors, or unsupported SVG stroke values at build-time.

✓ Safe System Refactoring

Rename and migrate icon primitives across hundreds of files safely with automated TypeScript refactoring.

✓ Inline JSDoc Documentation

Hover over any icon component in your IDE to see its bounding box, stroke defaults, and tags.

Verified TypeScript Icon Libraries (11)

#1

Lucide Icons

TypeScript ✓
⭐ 12,000◆ 1,960 iconsISC

A clean, consistent open-source icon library with 1960+ icons, forked from Feather Icons with active maintenance and TypeScript support.

npm install lucide-react
Full Guide & Catalog →✓ Tree-shakable
#2

Heroicons

TypeScript ✓
⭐ 21,000◆ 324 iconsMIT

Beautiful hand-crafted SVG icons by the makers of Tailwind CSS. Available in outline and solid styles with 324 icons.

npm install @heroicons/react
Full Guide & Catalog →✓ Tree-shakable
#3

Tabler Icons

TypeScript ✓
⭐ 18,000◆ 6,147 iconsMIT

Over 6100 free MIT-licensed high-quality SVG icons. One of the largest free icon libraries available for web projects.

npm install @tabler/icons-react
Full Guide & Catalog →✓ Tree-shakable
#4

PatternFly Icons

TypeScript ✓
⭐ 2,400◆ 2,884 iconsMIT

Red Hat's PatternFly icon system with 2,800+ MIT-licensed React icons for enterprise consoles, admin dashboards, developer tools, and product UIs.

npm install @patternfly/react-icons
Full Guide & Catalog →✓ Tree-shakable
#5

Untitled UI Icons

TypeScript ✓
⭐ 0◆ 1,179 iconsMIT

Official MIT-licensed React icons from Untitled UI, with 1,179 crisp outline icons for SaaS products, dashboards, and modern product interfaces.

npm install @untitledui/icons
Full Guide & Catalog →✓ Tree-shakable
#6

Phosphor Icons

TypeScript ✓
⭐ 8,000◆ 1,533 iconsMIT

Flexible icon family with 6 weights including thin, light, regular, bold, fill and duotone. Over 1500 icons available.

npm install @phosphor-icons/react
Full Guide & Catalog →✓ Tree-shakable
#7

Radix Icons

TypeScript ✓
⭐ 5,000◆ 318 iconsMIT

A crisp set of 15x15 icons designed by the WorkOS team. Perfectly sized for dense UIs and dashboards.

npm install @radix-ui/react-icons
Full Guide & Catalog →✓ Tree-shakable
#8

Iconoir

TypeScript ✓
⭐ 5,200◆ 1,384 iconsMIT

A high-quality, open-source icon library featuring over 1,300 meticulously crafted line icons. Highly consistent, premium aesthetic perfect for modern UIs.

npm install iconoir-react
Full Guide & Catalog →✓ Tree-shakable
#9

IonIcons

TypeScript ✓
⭐ 17,200◆ 1,300 iconsMIT

Premium, carefully designed icons by the Ionic Framework team. Provides Outline, Filled, and Sharp variants with over 1300 icons for responsive mobile and web apps.

npm install react-ionicons
Full Guide & Catalog →✓ Tree-shakable
#10

Octicons

TypeScript ✓
⭐ 10,400◆ 280 iconsMIT

GitHub's official icon set designed specifically for developer dashboards, code repositories, git histories, and developer utilities.

npm install @primer/octicons-react
Full Guide & Catalog →✓ Tree-shakable
#11

Ant Design Icons

TypeScript ✓
⭐ 8,700◆ 840 iconsMIT

The official icon set for Ant Design (AntD), featuring over 800 highly consistent icons in Outlined, Filled, and TwoTone themes for enterprise UIs.

npm install @ant-design/icons
Full Guide & Catalog →✓ Tree-shakable

LIBRARIES REQUIRING MANUAL TYPE DEFINITIONS (7)

Remix Icon3,229 icons · Apache 2.0
View Catalog →
Feather Icons287 icons · MIT
View Catalog →
Bootstrap Icons2,078 icons · MIT
View Catalog →
Devicons800 icons · MIT
View Catalog →
Teenyicons1,200 icons · MIT
View Catalog →
Circum Icons288 icons · MPL-2.0
View Catalog →
Elusive Icons304 icons · OFL-1.1
View Catalog →
FREQUENTLY ASKED QUESTIONS

TypeScript & SVG Icons FAQ

What is the standard TypeScript type for React SVG icon components?

Most modern libraries export a dedicated prop interface (e.g., `LucideProps` from lucide-react) or extend standard SVG component props: `React.ComponentPropsWithoutRef<"svg"> & { size?: number | string; strokeWidth?: number | string }`. This ensures full compatibility with standard HTML SVG attributes.

How does verbatimModuleSyntax affect SVG icon imports in TypeScript 5+?

With `verbatimModuleSyntax: true` enabled in tsconfig.json, TypeScript strictly distinguishes type imports from runtime value imports. Value imports like `import { Home } from "lucide-react"` will be preserved as runtime JS, while type imports like `import type { LucideIcon } from "lucide-react"` are completely stripped at compile time.

How do I build a generic dynamic Icon component in TypeScript without bundling all icons?

Define an explicit string union type (e.g., `type IconName = "home" | "settings" | "user"`) and map each key to a statically imported component in an internal map object. TypeScript will provide strict compile-time autocomplete and prevent invalid string keys.

Why do some legacy icon packages have missing or broken .d.ts declaration files?

Older libraries published before the ESM migration frequently shipped CommonJS-only code or generated declarations with ambient namespaces that fail under strict modern `moduleResolution: "bundler"` or `"node16"`. All libraries highlighted on this page ship native .d.ts or .d.mts declarations.

Explore Next.js & React Guides

Learn how to render typed icons in Next.js Server Components and React.

React Guide →Next.js Guide →

Disclaimer: IconSearch is an independent open-source discovery platform and is not affiliated with, sponsored by, or endorsed by Microsoft, TypeScript, or any featured icon library maintainers.