0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…
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. Each icon is one SVG file, fetched from <base-path>/<set>/<name>.svg (default /cdn/icons/lucide/home.svg), sanitized, cached, and rendered inline in shadow DOM. Icons inherit the current text color and can be sized using preset values.
For a single monochrome icon, [data-icon] is a terser alternative to <icon-wc>. Add it to a native <i>, <span>, or <button> and set the value to an icon name — no wrapper element required. A core-loaded enhancer sets a --vb-icon custom property, which a CSS ::before mask renders in currentColor.
Basic [data-icon] usage
12345
<idata-icon="star"aria-hidden="true"></i><spandata-icon="home"aria-hidden="true"></span><!-- Icon coexists with text via ::before — no wrapper markup needed --><buttontype="button"data-icon="x">Close</button>
Sizing
The icon is sized 1em, so it scales with the element's font-size. There is no sizeattribute — set font-size instead.
Set data-icon-set on the element itself, on an ancestor, or on <html> to change the icon set for every [data-icon] beneath it. Resolution checks the element first, then the nearest ancestor, then <html data-icon-set>, falling back to lucide.
Per-element and document-wide icon set
12345
<!-- Override on a single icon --><spandata-icon="star"data-icon-set="tabler"aria-hidden="true"></span><!-- Set the default for the whole document --><htmllang="en"data-icon-set="tabler">
Icon name (required). Matches filename without .svg extension.
set
string
nearest data-icon-set, else "lucide"
Icon set directory: lucide, phosphor, tabler, mage, bold, or custom for project-specific icons. See Icon sets and paths.
size
string
"md"
Size preset: xs, sm, md, lg, xl, 2xl
label
string
-
Accessible label for functional icons. When set, the icon is announced as an image with this name; without it the icon is hidden from assistive tech. Adding or removing it later updates the icon live.
base-path
string
<html data-icon-path>, else icons/ beside the loaded bundle
Icon base URL for this one icon. Usually you set data-icon-path on <html> instead.
data-flip-rtl
boolean
-
Mirror the glyph horizontally in right-to-left contexts. See RTL mirroring.
data-animate
"spin"
-
Spin the icon while an ancestor has data-loading. Disabled under prefers-reduced-motion.
Set when the icon could not be loaded from the requested set or the Lucide fallback. The icon dims, and any light-DOM content inside the element is shown instead.
data-upgraded
Set while the element is connected and upgraded.
Icon sets and paths
Without a setattribute, an icon uses the nearest data-icon-set: on the element itself, on any ancestor, then on <html>, falling back to lucide. This is the same resolution the [data-icon] primitive uses, and it is live: changing data-icon-set on an ancestor or on <html> (as the theme picker does) re-renders the icons beneath it.
Document-wide and per-section icon sets
12345678
<htmllang="en"data-icon-set="tabler"> …<sectiondata-icon-set="phosphor"><icon-wcname="bell"></icon-wc><!-- phosphor --><icon-wcname="bell"set="mage"></icon-wc><!-- the attribute wins --></section><icon-wcname="bell"></icon-wc><!-- tabler --></html>
Fallback to Lucide
The alternative sets are small. When the requested set does not contain an icon, <icon-wc> renders the Lucide icon of the same name instead. To avoid a failed request per missing icon, it reads the set's name manifest (<base-path>/<set>.json, loaded once per set) and goes straight to Lucide for names it does not list. The custom set skips the manifest, so you can add files to it without regenerating anything. Missing icons are remembered, so each one is requested at most once per page.
Serving icons from another path
Icons load from the icons/ folder beside the Vanilla Breeze script the page loaded. A page that links https://unpkg.com/vanilla-breeze/dist/cdn/vanilla-breeze.js gets its icons from that CDN, and a page that serves the bundle from /my-repo/cdn/ gets them from /my-repo/cdn/icons, with no setting. The location is read from the <script src> whose name contains vanilla-breeze; without one the base is /cdn/icons.
Set data-icon-path on <html> when the icons live somewhere else, such as a copy in your own assets, or when you bundle Vanilla Breeze into your own script. It applies to every <icon-wc> and every [data-icon], and it does not follow <base href>.
Icons from a copy in your own assets
12
<!-- Copied from node_modules/vanilla-breeze/dist/cdn/icons --><htmllang="en"data-icon-path="/assets/vb/icons">
Sizes
Use the sizeattribute to control icon dimensions. Sizes are relative to the current font size.
Icons work naturally inside buttons. An icon-only button needs exactly one accessible name: label the button or the icon, not both, or some screen readers announce it twice.
Icons in buttons
123456789101112131415
<!-- Icon with text label --><buttontype="button"><icon-wcname="plus"></icon-wc> Add Item</button><!-- Icon-only button: name the button, keep the icon decorative --><buttontype="button"class="ghost"aria-label="Settings"><icon-wcname="settings"></icon-wc></button><!-- …or let the labelled icon name the button --><buttontype="button"class="ghost"><icon-wcname="settings"label="Settings"></icon-wc></button>
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
Put project-specific SVGs in the custom/ folder under your icon base path (by default /cdn/icons/custom/; in this repository the source lives in src/icons/custom/) and reference them with set="custom".
Custom icon set usage
12345678910
<!-- Using a custom icon --><icon-wcname="logo"set="custom"></icon-wc><!-- Custom icon requirements: - SVG format with viewBox attribute - No fixed width/height needed (the component removes them) - Paint with currentColor via the file's own fill / stroke attributes: the component does not impose a stroke or fill, so filled and stroked icons both render as drawn-->
Accessibility
Decorative vs Functional Icons
Icons can be either decorative (hidden from screen readers) or functional (announced to screen readers).
<!-- Decorative - icon is hidden from screen readers --><button><icon-wcname="save"></icon-wc> Save Document</button><!-- Functional - the labelled icon names the button --><button><icon-wcname="x"label="Close dialog"></icon-wc></button><!-- Status icon with meaning of its own --><icon-wcname="alert-circle"label="Warning"></icon-wc>
RTL mirroring
Directional glyphs (arrows, chevrons, “undo”, “reply”) should point the other way in right-to-left text. Icons are not mirrored automatically, because most glyphs (checkmarks, clocks, media controls, logos) must not flip. Opt in per icon with data-flip-rtl; it only takes effect when the icon is in an RTL context (dir="rtl" on it or an ancestor).
Good candidates: arrow-left, arrow-right, chevron-left, chevron-right, chevrons-left, chevrons-right, undo, redo, reply, log-in, log-out, and text-direction icons such as list-indent-increase.
Loading spinner
Add data-animate="spin" to an icon that should rotate while its container is busy. The animation runs only while an ancestor has data-loading, and stops under prefers-reduced-motion: reduce.
Fetched SVG is sanitized before it is inserted: <script>, <foreignObject>, <iframe> and similar elements, every on* event-handler attribute, and javascript: / data: links are removed. Even so, serve icons only from origins you control.
Styling
Icons can be styled using CSS. The component uses Shadow DOM but allows color inheritance.
Icon styling with CSS
123456789101112131415
/* Change icon color */.dangericon-wc {color: var(--color-error);}/* Custom sizing via CSS */icon-wc.hero-icon {inline-size: 4rem;block-size: 4rem;}/* Hover effects */button:hovericon-wc {color: var(--color-interactive-hover);}
JavaScript API
The component exposes read-only properties that report its resolved configuration. Change it through attributes.