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

svg

The SVG element embeds scalable vector graphics with size variants, color options, and built-in animations for icons and illustrations.

Description

The <svg> element embeds Scalable Vector Graphics directly in HTML. SVG is resolution-independent, accessible, and styleable with CSS. Vanilla Breeze provides size classes, color variants, and animation utilities for inline SVG.

Unlike raster images, SVG scales to any size without quality loss, making it ideal for icons, logos, and illustrations.

When to Use

  • Icons - UI icons that need to scale and change color
  • Logos - Brand marks that must be crisp at any size
  • Illustrations - Vector artwork and diagrams
  • Charts - Accessible data visualizations
  • Animations - Animated graphics via CSS or SMIL

When to Use Other Elements

  • Use <img> for photographs and complex raster images
  • Use <picture> for responsive raster images with multiple sources
  • Use <canvas> for dynamic, pixel-based graphics
  • Use <icon-wc> for the icon component with sprite support

Size Variants

Predefined size classes for consistent icon sizing across your application.

Class Size Use Case
.xs 0.75rem (12px) Inline indicators, badges
.s 1rem (16px) Small icons in text
.m 1.5rem (24px) Default icon size, buttons
.l 2rem (32px) Featured icons, nav items
.xl 3rem (48px) Hero icons, empty states
.xxl 4rem (64px) Large illustrations

Color Variants

Colour classes set the icon's color and, for fill-style icons, fill: currentColor. They work for both icon styles:

  • Fill-style icons (no fill attribute on the <svg>): the shapes are filled with the colour.
  • Stroke-style icons (fill="none" stroke="currentColor" on the <svg>, the Lucide style VB uses): the class leaves fill="none" alone, so the icon stays an outline, and the stroke follows the colour.

currentColor Pattern

Use currentColor in your SVG to inherit the CSS color property. Icons then match the surrounding text, change with the theme and dark mode, and follow system colours in forced-colors mode.

Dark Mode and Forced Colors

An SVG with no fill and no class is painted black, which disappears on a dark theme. Give every icon a colour source: currentColor (directly or through .currentcolor, .interactive or .muted), or a token such as var(--color-text). Hardcoded hex fills do not adapt to themes or dark mode.

In forced-colors mode (Windows High Contrast) the browser replaces text colours with system colours. Icons drawn with currentColor follow along; fills from colour tokens or literal colours may not. Draw any icon that carries meaning with currentColor.

Animations

Built-in animation classes for loading indicators and attention-grabbing icons.

Respecting Motion Preferences

Built in: .spin and .pulse stop when the OS asks for reduced motion (prefers-reduced-motion: reduce) or when the page sets VB's own switch, data-motion-reduced on <html> (written by the settings panel). You do not need to add the media query yourself. A stopped spinner no longer signals activity on its own, so pair it with visible or announced text such as "Loading…".

Responsive SVG

.full makes an SVG fill its container's width; the viewBox sets the aspect ratio, so the height follows.

An SVG with no class at all is capped at its container's width (max-inline-size: 100%), with the height following the viewBox.

Icons in Context

An inline icon in running text, icons in buttons (with and without visible text), and an icon grid.

Security: Untrusted SVG

Inline SVG is live markup. If you insert SVG from user content, an API or a file upload with innerHTML, any <script>, on* event attribute or javascript: link inside it runs on your page.

  • Show untrusted SVG with <img src="file.svg">. An SVG loaded as an image cannot run scripts or reach the page.
  • Only inline it when you need CSS or currentColor control, and sanitize it first. VB's <icon-wc> already runs every fetched icon through its sanitizeSVG helper, which strips scripts, event handlers and script URLs.

Accessibility

Decorative Icons

Icons that don't convey information should be hidden from assistive technology.

Informative Icons

Icons that convey meaning need accessible names.

Interactive Icons

Wrap icons in buttons or links with proper labels.

Best Practices

  • Use aria-hidden="true" on decorative icons
  • Give meaningful icons role="img" and a name: aria-labelledby pointing at a <title>, or aria-label
  • Draw meaningful icons with currentColor so they survive dark mode and forced-colors mode
  • Don't rely on icons alone - pair with visible text when possible
  • Ensure sufficient color contrast (3:1 against the background for icons that carry meaning)
  • Spinners and pulses stop under reduced motion; never let them be the only sign of a state
  • Test with screen readers

Related

  • <icon-wc> - VB's icon component wraps SVG with sprite support and consistent sizing
  • <img> - For raster images (photographs, screenshots) or external SVG files via <img src="icon.svg">
  • <picture> - For responsive raster images with multiple sources and art direction
  • <canvas> - For dynamic pixel-based graphics
  • <figure> - Wrap SVG diagrams with captions

CSS Reference

Styles defined in /src/native-elements/svg/styles.css

Selector Properties
svg display: inline-block; vertical-align: middle; overflow: visible;
svg:not([class]) max-inline-size: 100%; block-size: auto;
svg.xs inline-size: 0.75rem; block-size: 0.75rem;
svg.s inline-size: 1rem; block-size: 1rem;
svg.m inline-size: 1.5rem; block-size: 1.5rem;
svg.l inline-size: 2rem; block-size: 2rem;
svg.xl inline-size: 3rem; block-size: 3rem;
svg.xxl inline-size: 4rem; block-size: 4rem;
svg.currentcolor:not([fill="none"]) fill: currentColor;
svg.interactive color: var(--color-interactive);
svg.muted color: var(--color-text-muted);
svg:is(.interactive, .muted):not([fill="none"]) fill: currentColor;
svg.full inline-size: 100%; block-size: auto;
svg.spin animation: svg-spin 1s linear infinite;
svg.pulse animation: svg-pulse 2s ease-in-out infinite;
svg:is(.spin, .pulse) in @media (prefers-reduced-motion: reduce) animation: none;
:root[data-motion-reduced] svg:is(.spin, .pulse) animation: none;
↑