0.5.0 is the first element quality release, covering every A, B and C element. Components rebuild cleanly when moved or re-populated, keyboard and screen-reader access is fixed across the C components, and several XSS paths are closed. Themes gain a --btn-border-width hook,…
Universal switchable host for VB lens components. Wraps a set of light-DOM lens children and exposes reader controls to switch which one is active.
Overview
The <content-lens> component is the universal host for VB's lens family. It wraps any number of lens children (each carrying a data-lens-nameattribute) and renders a reader-facing radio control so visitors can switch between views over the same underlying data.
Without JavaScript, every lens child is rendered stacked — the page remains usable.
Required. Registers the child as a lens; the value is what data-lens-default, setLens() and the event detail refer to
data-lens-label
string
humanised name
Chip text. Defaults to data-lens-name with dashes turned into spaces and words capitalised (by-topic → “By Topic”)
Shared source forwarding
data-lens-src is copied onto every lens child that has neither its own data-lens-src nor a src. Forwarding does not depend on upgrade order: a child that was already upgraded before the host (its definition loaded first) is re-initialised once the attribute arrives. <popularity-index> treats the forwarded URL as its metadata source only; its analytics endpoint lives on its own analytics-srcattribute.
JavaScript API
Member
Type
Description
activeLens
string (read-only)
Name of the visible lens; empty before the element upgrades
setLens(name)
method
Show the named lens, check its chip and persist the choice. Unknown names are ignored
Reader switches lenses, or setLens() changes the active lens. Not fired for the initial selection (default or restored from sessionStorage), on reconnect, or when setLens() names the lens already showing — read activeLens or data-active-lens for the starting state
Keyboard
The chips are native radio buttons, so the browser's radio-group keyboard model applies.
Key
Action
Tab
Moves focus into the group (onto the checked chip) and out again
Arrow keys
Move to the previous / next chip and switch to that lens
Space
Selects the focused chip if it is not already checked
Accessibility
The controls are a <fieldset> with a “View” <legend> wrapping real radio inputs, so screen readers announce the group name, each lens label and the checked state. No extra landmark is added.
The radio inputs are visually clipped, not hidden: the chip (<label>) shows the focus ring whenever its radio has :focus-visible, using the theme focus-ring tokens.
Inactive lenses get hidden, which removes them from the accessibility tree and the tab order.
Progressive Enhancement
Before the script upgrades the host (or without JavaScript), every lens child is shown, stacked and separated by a top border, and no chips are rendered. Lens children that render from data-lens-src need JavaScript themselves, so author meaningful light-DOM fallback content inside them where you can.
Reader sovereignty
The lens family follows VB's reader-sovereignty principle: the author defines the exposed view, the reader can always reframe.<content-lens> exposes the radio chips by default; authors who want to lock to a single view can set data-lens-controls="off", but the underlying data is still discoverable via the shared data-lens-src.