icon-wc
SVG icons with Lucide integration, consistent sizing, and automatic accessibility.
Overview
The <icon-wc> component provides a simple way to use SVG icons from the Lucide library or custom icon sets. Icons inherit the current text color and can be sized using preset values.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
name |
string | - | Icon name (required). Matches filename without .svg extension. |
set |
string | "lucide" |
Icon set directory. Use "custom" for project-specific icons. |
size |
string | "md" |
Size preset: xs, sm, md, lg, xl, 2xl |
label |
string | - | Accessible label for functional icons. When set, icon is announced to screen readers. |
base-path |
string | "/.assets/icons" |
Override the default icon path. |
Sizes
Use the size attribute to control icon dimensions. Sizes are relative to the current font size.
Size Reference
| Size | Dimensions |
|---|---|
xs |
1em (16px at base) |
sm |
1.25em (20px) |
md |
1.5em (24px) |
lg |
2em (32px) |
xl |
2.5em (40px) |
2xl |
3em (48px) |
Colors
Icons inherit currentColor from their parent element. Change the parent's color property to change the icon color.
With Buttons
Icons work naturally inside buttons. For icon-only buttons, always include an accessible label.
Lucide Integration
The component uses the Lucide icon library by default. Lucide provides over 1,900 beautifully crafted open-source icons.
Icon Categories
| Purpose | Icon Names |
|---|---|
| Navigation | menu, x, arrow-left, arrow-right |
| Actions | plus, minus, edit, trash, save |
| Status | check, x, alert-circle, info |
| Media | play, pause, volume-2, image |
| User | user, users, settings, log-out |
| Files | file, folder, download, upload |
| Social | share, heart, star, message-circle |
Custom Icons
Add custom icons to the .assets/icons/custom/ directory and reference them with set="custom".
Accessibility
Decorative vs Functional Icons
Icons can be either decorative (hidden from screen readers) or functional (announced to screen readers).
| Context | Pattern |
|---|---|
| Icon + visible text | No label needed (decorative) |
| Icon-only button | Add label attribute |
| Status indicator | Add label describing status |
| Purely decorative | No label needed |
Styling
Icons can be styled using CSS. The component uses Shadow DOM but allows color inheritance.
JavaScript API
The component exposes properties that mirror its attributes.