Overview
TheIcon component renders SVG icons from a predefined icon library. It supports custom colors, gradients, and sizing, making it a versatile component for adding visual elements throughout the portfolio.
Props
The name of the icon to display. Available icons are defined in
IconPaths.ts.The color of the icon. Can be any valid CSS color value.
Whether to apply a gradient fill to the icon instead of a solid color.
Custom size for the icon. Accepts any CSS size value (e.g., “1.5em”, “24px”).
Usage
Basic Icon
Colored Icon
Icon with Gradient
Custom Sized Icon
Real-World Examples
Homepage Roles
Fromsrc/pages/index.astro:72-74:
Navigation Logo
Fromsrc/components/Nav.astro:27:
Call to Action Arrows
Fromsrc/pages/index.astro:111:
Available Icons
Common icons available in the portfolio:- Development:
code,terminal-window,github-logo - Social Media:
twitter-logo,youtube-logo,dribbble-logo,codepen-logo,twitch-logo - Navigation:
arrow-right,list,menu - UI Elements:
sun,moon-stars(for theme toggle) - General:
rocket-launch,pencil-line,strategy
The complete list of available icons is defined in
src/components/IconPaths.ts. To add new icons, add their SVG path data to this file.Implementation Details
The Icon component:- Uses a 256x256 viewBox for consistent scaling
- Defaults to 1em width/height for inline text alignment
- Supports gradient overlays with unique IDs to prevent conflicts
- Sets
aria-hidden="true"for decorative icons
Gradient System
Whengradient={true} is used, the component generates a unique gradient ID and applies a linear gradient with three color stops using CSS custom properties:
Accessibility
Icons are marked asaria-hidden="true" by default. When using icons to convey meaning (not just decoration), wrap them in elements with appropriate ARIA labels or provide alternative text.