Icon
The Icon component provides a unified interface for rendering SVG icons with support for dynamic loading, size control, color theming, and comprehensive error handling. It loads SVG files on-demand and offers fine-grained control over appearance.
Icon Library
Available icons in the design system
UI Icons
<Icon src="/svg/home.svg" /><Icon src="/svg/rounded-magnifer.svg" /><Icon src="/svg/ui_icons/code-file.svg" /><Icon src="/svg/ui_icons/user.svg" />Semantic Icons
<Icon src="/svg/ui_icons/semantic/check-circle.svg" semantic="success" /><Icon src="/svg/ui_icons/semantic/danger.svg" semantic="warning" /><Icon src="/svg/ui_icons/semantic/shield-check.svg" semantic="info" /><Icon src="/svg/ui_icons/semantic/trash-bin-trash.svg" semantic="error" />API Reference
Props
| Prop | Type | Default | Description |
|---|---|---|---|
src | string | undefined | Path to SVG file |
size | number \| string | 20 | Size in pixels or CSS units |
color | string | 'currentColor' | Direct color control |
strokeWidth | number | 1.25 | SVG stroke width |
alt | string | '' | Alt text for accessibility |
role | string | 'img' | ARIA role |
ariaHidden | boolean | false | Hide from screen readers |
class | string | '' | Additional CSS classes |
style | string | '' | Inline styles if needed |
Icon Libraries
The project includes four icon categories:
- UI Icons (
/svg/ui_icons/): Interface and action icons - Dev Logos (
/svg/dev_logos/): Technology and framework logos - Arrows (
/svg/arrows/): Directional and navigation arrows - Spinners (
/svg/spinners/): Loading and progress indicators
Usage Examples
Basic Icon
<Icon src="/svg/ui_icons/home.svg" /> Sized Icon
<Icon src="/svg/ui_icons/search.svg" size={24} />
<Icon src="/svg/ui_icons/filter.svg" size="2rem" /> Colored Icon
<Icon
src="/svg/ui_icons/semantic/check-circle.svg"
color="var(--color-semantic-success)"
/> Button with Icon
<Button variant="primary">
<Icon src="/svg/ui_icons/save.svg" size={16} />
Save Changes
</Button> Icon States
<!-- Loading state -->
<Icon src="/api/slow-icon.svg" />
<!-- Error state -->
<Icon src="/invalid/path.svg" />
<!-- Decorative icon -->
<Icon
src="/svg/ui_icons/star.svg"
ariaHidden={true}
/> Custom Stroke Width
<Icon
src="/svg/arrows/arrow-right.svg"
strokeWidth={2}
size={32}
/> Icon Categories
UI Icons
Common interface icons for actions, navigation, and status indicators:
- Files:
document,folder,code-file - Actions:
edit,trash,refresh,save - Navigation:
menu,close,search,filter - Status:
check-circle,info-circle,warning-triangle
Development Logos
Technology and framework logos for documentation and portfolios:
- Languages:
javascript,typescript,python,rust - Frameworks:
svelte,react,vue,angular - Tools:
vscode,git,docker,kubernetes
Arrows
Directional indicators for navigation and UI interactions:
- Basic:
arrow-up,arrow-down,arrow-left,arrow-right - Diagonal:
arrow-up-right,arrow-down-left - Special:
chevron-down,caret-right,return-arrow
Spinners
Loading indicators for async operations:
- Types:
dots,rings,bars,pulse - All spinners automatically animate when used
Design Tokens
The Icon component uses the following design tokens:
- Colors: Inherits from
currentColorby default - Transitions:
--transition-basefor smooth state changes - Semantic colors:
--color-semantic-errorfor error states - Animation: Built-in pulse animation for loading states
Loading & Error States
Loading State
When an icon is loading, a three-dots spinner is displayed automatically:
- Same size as the requested icon
- Inherits the specified color
- Smooth transition when icon loads
Error State
If an icon fails to load, an X mark is displayed:
- Uses
--color-semantic-errorcolor - Maintains the requested size
- Console error for debugging
Empty State
Before an icon loads or if no src is provided:
- Displays a placeholder with 10% opacity
- Maintains layout stability
- Prevents content shift
Performance Considerations
- Icons are loaded on-demand via fetch
- SVG content is inlined for maximum control
- Cached in browser for repeated use
- Automatic detection of stroke vs fill-based icons
- Efficient re-rendering on prop changes
Accessibility
- Semantic
role="img"by default aria-labelsupport viaaltproparia-hiddenfor decorative icons- Proper focus handling in interactive contexts
- Screen reader friendly error states
Best Practices
- Use semantic paths: Organize icons by purpose (
/svg/ui_icons/semantic/) - Size appropriately: 16px for inline, 20px for buttons, 24px+ for headers
- Color inheritance: Use
currentColorfor theme compatibility - Loading states: Icons automatically show loading state during fetch
- Accessibility: Always provide
alttext for meaningful icons - Performance: Icons are cached by the browser after first load