Skip to main content

Type Definition

Overview

IconBaseProps is the foundational TypeScript interface that defines the props accepted by all icon components in React Icons. It extends React’s SVGAttributes<SVGElement>, meaning all standard SVG element attributes are supported in addition to the icon-specific properties.

Properties

Icon-Specific Properties

string | number
Specifies the width and height of the icon.Accepted Values:
  • Number: Interpreted as pixels (e.g., 24 becomes “24px”)
  • String: Any valid CSS size unit (e.g., “1em”, “24px”, “1.5rem”, “100%”)
Default: "1em" (if not specified in props or IconContext)Example:
string
Specifies the color of the icon.Accepted Values:
  • Hex colors: "#3b82f6"
  • RGB/RGBA: "rgb(59, 130, 246)", "rgba(59, 130, 246, 0.5)"
  • Named colors: "blue", "red", "currentColor"
  • HSL: "hsl(217, 91%, 60%)"
Default: Inherits from IconContext or uses "currentColor"Example:
string
Provides an accessible title for the icon via an SVG <title> element.Accessibility: Screen readers will announce this text when the icon is focused or encountered. Use this for icons that convey meaning or serve as interactive elements.Example:
Rendered Output:
React.ReactNode
Additional child elements to render inside the SVG element.Usage: Typically used internally by the library or when creating custom icons with IconBase.Example:

Inherited SVG Attributes

Since IconBaseProps extends React.SVGAttributes<SVGElement>, all standard SVG attributes are supported:
string
CSS class name(s) to apply to the icon.
React.CSSProperties
Inline styles to apply to the icon.
React.MouseEventHandler<SVGElement>
Click event handler.
React.MouseEventHandler<SVGElement>
Mouse enter event handler.
React.MouseEventHandler<SVGElement>
Mouse leave event handler.
string
ARIA attributes for accessibility.
string
Custom data attributes.
And many more standard SVG/DOM attributes including:
  • id, tabIndex, role
  • onFocus, onBlur, onKeyDown, onKeyUp
  • transform, opacity, clipPath
  • All other SVGAttributes

Usage Examples

Basic Usage

With Event Handlers

With Tailwind CSS

Responsive Sizing

Custom Icon with IconBase

Type Usage

Typing Custom Icon Components

Extending IconBaseProps

In Function Parameters

Source Reference

The IconBaseProps interface is defined in:
  • iconBase.tsx:31-36 - Interface definition