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

hide-until-ready

CSS-only FOUC guards for custom elements: hide an element until its definition loads (with a no-JS and timeout escape), or show placeholder content until then.

Overview

A custom element renders its raw children until its JavaScript defines it, which can flash unstyled markup (FOUC). Two CSS-only attributes handle that gap:

They key off :defined, so they only make sense on custom elements: a native element is always defined. (Unprefixed attributes are valid on custom elements.)

Usage

Prefer components that look right before they upgrade — most VB components do (a <tab-set> is a working accordion without JavaScript). Reach for hide-until-ready only when the raw markup really is worse than nothing.

Options

Both attributes are boolean. The complete CSS (src/utils/readiness.css):

Never hidden for good

  • No JavaScript — under @media (scripting: none) nothing is hidden, because nothing would ever define the element.
  • Timeout — if scripting is on but the definition never arrives (a blocked or failed module, a CSP error, a 404), the content is revealed after --vb-until-ready-timeout (default 3s). Set it on :root to change it. A one-shot animation on the root flips --vb-until-ready from waiting to expired; the hide rule is a container style query on that value. Browsers without container style queries never hide the element (you get the FOUC, not lost content). Do not set animation on :root yourself, or the timer is replaced.
  • VB's CSS-only elements (<layout-stack>, <layout-card>, <user-avatar>…) are defined inertly by VB, so on them the attribute has no effect.

It always wins

The rules live in the lowest framework layer with !important (like [hidden]), so a component that locks its own display (<content-swap>'s display: grid !important) or your own unlayered display rule cannot un-hide it.

Events

None. To run code when an element is defined, use customElements.whenDefined('tag-name').

Styling

Hiding and revealing changes layout: the element takes no space while hidden. To avoid a shift, reserve its space on a placeholder (min-block-size) or with contain-intrinsic-size, as the demo does.

Placeholders

Prefer a sibling placeholder that steps aside with :has(). It is a plain element, so it never upgrades into a second component:

show-until-ready goes on an element with the same tag as the component. Once the tag is defined that placeholder upgrades too (its connectedCallback runs, so a <chart-wc> placeholder may render or fetch) and is merely hidden. Use it only for light components; for heavy ones, use a sibling placeholder or the component's own loading state (data-loading="skeleton").

Accessibility

  • Hidden content is out of the accessibility tree and the tab order until it appears. Appearing is not announced.
  • A placeholder such as “Loading chart…” is read while visible and removed without announcement. For a long wait, mark the region aria-busy="true" and clear it when the content is ready.
  • With JavaScript off nothing is hidden, and the timeout reveals content whose script failed, so no content is lost for good.

Related

↑