Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

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…

Read the release notes

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. 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.

The [data-icon] Primitive

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.

Sizing

The icon is sized 1em, so it scales with the element's font-size. There is no size attribute — set font-size instead.

Switching Icon Sets

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.

Attributes

Attribute Type Default Description
name string - 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.

State attributes

Attribute Description
data-error 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 set attribute, 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.

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>.

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. An icon-only button needs exactly one accessible name: label the button or the icon, not both, or some screen readers announce it twice.

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".

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

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.

Security

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.

JavaScript API

The component exposes read-only properties that report its resolved configuration. Change it through attributes.

↑