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…
Click-to-flip-attribute upscale. Toggles a boolean attribute, ARIA two-state value, custom on/off value, or CSS class on a target — the catch-all for the recurring 'change state' pattern that doesn't have a native primitive.
Overview
The data-toggle attribute upscales a <button> with click-to-flip-attribute behavior. Three modes are auto-detected from the spec, plus a class:name shorthand. aria-controls and aria-pressed / aria-expanded are wired automatically where it makes sense.
Three modes (auto-detected)
1. Boolean attributes
Standard boolean HTML attrs (hidden, disabled, open, checked, readonly, …). Toggles attributepresence: absent ↔ present.
CSS selector for the target. Omit for self-toggling.
data-toggle-on
"true"
"On" value for custom mode. Set to "open" to enable aria-expanded auto-wiring.
data-toggle-off
"false"
"Off" value for custom mode.
Events
The button emits toggle:change after each click.
JS
123456
btn.addEventListener('toggle:change', (e) => {const { spec, value, present, target } = e.detail;// spec: "hidden" | "data-state" | "class:expanded" | ...// present: true if attr/class is now applied// value: the new attribute value (for non-boolean / non-class modes)});
Accessibility
aria-controls — set on the button to the target's id when the target is external (not self).
aria-pressed — reflected on the button when self-toggling a boolean attribute (e.g. a "Mute" toggle).
aria-expanded — reflected on the button when the target has [popover], OR when data-toggle-on="open" is set on a data-state toggle (a common disclosure pattern).
Native button — keyboard activation (Enter / Space) just works.
When to reach for native instead
Several other primitives cover overlapping shapes — pick the one closest to your use case:
If you want to…
Use
Open a popover
Native popovertarget (no JS needed)
Invoke a registered command (close, open, …) on a target
Native commandfor + command (works with <dialog>, [popover] and custom -- commands). VB does not polyfill it; it only lists [commandfor] buttons in <command-palette discover>.