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
Specifies the width and height of the icon.Accepted Values:
- Number: Interpreted as pixels (e.g.,
24becomes “24px”) - String: Any valid CSS size unit (e.g., “1em”, “24px”, “1.5rem”, “100%”)
"1em" (if not specified in props or IconContext)Example: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%)"
"currentColor"Example:Provides an accessible title for the icon via an SVG Rendered Output:
<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: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
SinceIconBaseProps extends React.SVGAttributes<SVGElement>, all standard SVG attributes are supported:
CSS class name(s) to apply to the icon.
Inline styles to apply to the icon.
Click event handler.
Mouse enter event handler.
Mouse leave event handler.
ARIA attributes for accessibility.
Custom data attributes.
id,tabIndex,roleonFocus,onBlur,onKeyDown,onKeyUptransform,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
TheIconBaseProps interface is defined in:
iconBase.tsx:31-36- Interface definition